如何通过 Clojure 互操作访问静态内部 Java 类? [英] How to access static inner Java class via Clojure interop?

查看:25
本文介绍了如何通过 Clojure 互操作访问静态内部 Java 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我需要做的是这个

Basically what I need to do is this

FileChannel.MapMode.READ_ONLY

我尝试做显而易见的事情

I tried doing the obvious

(.. FileChannel MapMode READ_ONLY)

但最终会抛出异常

java.lang.NoSuchFieldException: MapMode

即使是在 互操作文档 中指定的用于访问静态字段的 / 符号也会产生同样的异常

even the / notation specified as for access static fields in the interop documentation produces the same exception

(. (FileChannel/MapMode) READ_ONLY)

推荐答案

您可以使用 $

java.nio.channels.FileChannel$MapMode/READ_ONLY

请注意,如果您要导入 FileChannel,您还应该导入 FileChannel$MapMode.

Mind that if you are importing FileChannel you should also import FileChannel$MapMode.

这篇关于如何通过 Clojure 互操作访问静态内部 Java 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆