Java Class.getSimpleName() 和 .getName() 在 Cacao 和 Sun Java 上的行为不同

发布于 2024-08-03 03:29:48 字数 1435 浏览 2 评论 0原文

有谁知道为什么会发生这种情况?

这是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满地尘埃落定 2024-08-10 03:29:48

这很可能是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文