简体   繁体   English

在Jython中创建Java对象时,没有可见的类构造函数

[英]No Visible constructors for class when creating Java object in Jython

I am running the Jython shell. 我正在运行Jython Shell。 I was trying to mess around with a few Java classes in the shell, as I am a bit new to using the Jython implementation. 我试图弄乱外壳中的一些Java类,因为我对使用Jython实现有点陌生。 However, when I try to create an object, for example, I get the following Traceback. 但是,例如,当我尝试创建对象时,将获得以下Traceback。

>>> s = java.lang.annotation
>>> s.Annotation()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: No visible constructors for class (java.lang.annotation.Annotation)

I read this question and tried editing the python.security.respectJavaAccessibility line in my Jython registry to equal false , but that was to no avail. 我阅读了此问题,并尝试将Jython注册表中的python.security.respectJavaAccessibility行编辑为false ,但这无济于事。

What could be causing this to happen? 是什么导致这种情况发生?

Annotation is not a class, its an interface [ Documentation ] . Annotation不是一个类,它是一个interface [ Documentation ]。 You cannot instantiate an interface , you will have to create a class that implements the Annotation class and instantiate that class. 您不能实例化一个接口,您将不得不创建一个实现Annotation类的类并实例化该类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM