Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSimpleName() in java.lang.Class<T> broken for classes that are defined in objects #286

Closed
scabug opened this issue Dec 14, 2007 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 14, 2007

[http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getSimpleName() getSimpleName()] yields an "java.lang.!InternalError: Malformed class name" for Scala classes, which are defined inside Scala objects.

object Toast {
  class Egg {
    def eat = println(this.getClass.getSimpleName)
  }
}

object Main extends Application {
  new Toast.Egg().eat
}

yields

Exception in thread "main" java.lang.InternalError: Malformed class name
	at java.lang.Class.getSimpleName(Class.java:1129)
	at Toast$$Egg.eat(Test.scala:3)
	at Main$$.<init>(Test.scala:8)
	at Main$$.<clinit>(Test.scala)
	at Main.main(Test.scala)
@scabug
Copy link
Author

scabug commented Dec 14, 2007

Imported From: https://issues.scala-lang.org/browse/SI-286?orig=1
Reporter: Daniel Lorch (daniel)

@scabug
Copy link
Author

scabug commented Jan 14, 2008

@dragos said:
This happens because 'getSimpleName' is assuming the name has a certain pattern of '$$'s, which unfortunately is not the case when the class is defined inside a top-level object. The IBM JVM for instance is printing the right name, so this is an issue of Sun's implementation. Changing the naming scheme for objects requires quite a lot of thought so I postpone this issue for.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone postponed deleted

@scabug
Copy link
Author

scabug commented Feb 9, 2009

@paulp said:
This code did the right thing on all JVMs I have ready access to, but I didn't want to close it in case I just didn't find the right JVM. However, the fact that it worked on sun's linux JVM makes me suspect that the bug is no longer valid. Iulian, can you confirm or dispute this for me?

@scabug
Copy link
Author

scabug commented Feb 27, 2009

@paulp said:
Okay, I went all the way to trying this out on windows and it works. So I'm closing this as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants