Java Class.getSimpleName() 和 .getName() 在 Cacao 和 Sun Java 上的行为不同
有谁知道为什么会发生这种情况?
这是 Java DBus 绑定 (2.6) 中的
// don't let people import things which don't have a
// valid D-Bus interface name
System.out.println("type.getName: " + type.getName() + " type.getSimpleName: " + type.getSimpleName() );
if (type.getName().equals(type.getSimpleName())) {
throw new DBusException(_("DBusInterfaces cannot be declared outside a package: " + "type.getName: " + type.getName()
+ " type.getSimpleName: " + type.getSimpleName() ));
}
一些
@ubuntu:~/tmp/cacao$ java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)
@ubuntu:~/tmp/cacao$ cacao -version
java version "1.5.0"
CACAO version 0.99.3+hg
java -Djava.library.path=/usr/lib/classpath:/ho... DBusChat
type.getName: org.freedesktop.DBus type.getSimpleName: DBus
...Exception in thread "main" org.freedesktop.dbus.exceptions.DBusExecutionException: Could not get owner of name 'framez.tests.dbus.DbusChatInterface': no such name
修改
cacao -Djava.library.path=/usr/lib/classpath:/ho... DBusChat
type.getName: org.freedesktop.DBus type.getSimpleName: org.freedesktop.DBus
行?或者这是可可的一些奇怪的错误。
有谁知道 .getName() 是否与虚拟机相关?
信息:
两个 JVM 上的 GNU 类路径 0.98 DBus 绑定 2.6
Does any one have any idea why this would be happening?
This is some modified lines from the Java DBus bindings (2.6)
// don't let people import things which don't have a
// valid D-Bus interface name
System.out.println("type.getName: " + type.getName() + " type.getSimpleName: " + type.getSimpleName() );
if (type.getName().equals(type.getSimpleName())) {
throw new DBusException(_("DBusInterfaces cannot be declared outside a package: " + "type.getName: " + type.getName()
+ " type.getSimpleName: " + type.getSimpleName() ));
}
Now check out the difference in output from Cacao (0.99.4) versus Sun 1.5
@ubuntu:~/tmp/cacao$ java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)
@ubuntu:~/tmp/cacao$ cacao -version
java version "1.5.0"
CACAO version 0.99.3+hg
java -Djava.library.path=/usr/lib/classpath:/ho... DBusChat
type.getName: org.freedesktop.DBus type.getSimpleName: DBus
...Exception in thread "main" org.freedesktop.dbus.exceptions.DBusExecutionException: Could not get owner of name 'framez.tests.dbus.DbusChatInterface': no such name
versus...
cacao -Djava.library.path=/usr/lib/classpath:/ho... DBusChat
type.getName: org.freedesktop.DBus type.getSimpleName: org.freedesktop.DBus
The Exception is unimportant - its being caused by this behavior... Any ideas? Or is this some weird bug with Cacao.
Does anyone know if .getName() is a VM dependent thing?
Info:
GNU Classpath 0.98 on both JVMs
DBus bindings 2.6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很可能是 GNU Classpath 到 Cacao 平台的移植中的错误。如果我没记错的话,
java.lang.Class
的类路径版本中的大多数方法都委托给需要为库的每个端口实现的“vm”类。当然,
Class.getSimpleName()
应该返回没有包限定的类名。This is most likely a bug in the port of GNU Classpath to the Cacao platform. If I recall correctly, most of the methods in the Classpath version of
java.lang.Class
delegate to a "vm" class that needs to be implemented for each port of the library.Certainly
Class.getSimpleName()
should return the classname without the package qualification.