Java Class.getSimpleName() and .getName() behaving differently on Cacao versus Sun Java

29,967

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.

Share:
29,967
EdH
Author by

EdH

Updated on August 20, 2022

Comments

  • EdH
    EdH over 1 year

    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