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

Compiler generates invalid class names #3845

Closed
scabug opened this issue Sep 15, 2010 · 2 comments
Closed

Compiler generates invalid class names #3845

scabug opened this issue Sep 15, 2010 · 2 comments

Comments

@scabug
Copy link

scabug commented Sep 15, 2010

Code to reproduce:

package test

object ClassNameProblem {
	def main(args:Array[String]) {
		println( classOf[scala.swing.Action.Trigger].getName() )
		println( classOf[scala.swing.Action.Trigger.Wrapper].getEnclosingClass().getName )
		println( classOf[scala.swing.Action.Trigger.Wrapper].getName() )
		System.out.flush()
		println( classOf[scala.swing.Action.Trigger.Wrapper].getSimpleName() )
	}
}

This leads to the following output (and error):

scala.swing.Action$$Trigger
scala.swing.Action$$Trigger$$
scala.swing.Action$$Trigger$$Wrapper
Exception in thread "main" java.lang.InternalError: Malformed class name
	at java.lang.Class.getSimpleName(Class.java:1133)
	at test.ClassNameProblem$$.main(ClassNameProblem.scala:9)
	at test.ClassNameProblem.main(ClassNameProblem.scala)

The problem for scala.swing.Action.Trigger.Wrapper seems to be, that there is no "$$" as separator between the name of the enclosing class and its simple name. But this is expected by java.lang.Class#getSimpleName, which therefore throws the Exception.

In my understanding, class.getSimpleName should never fail. So this seems to be a bug of the Scala compiler.

You might ask, why on Earth one would call this method? Well, JRuby 1.5.1 does for some reason, if you give it e.g. the peer of a scala.swing.ToggleButton. So this problem makes Scala Swing somewhat unusable with JRuby.

Scala version: 2.8.0 [[br]]
Java version: 1.6.0_20 [[br]]
System: Mac OS

@scabug
Copy link
Author

scabug commented Sep 15, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3845?orig=1
Reporter: Tobias Vogele (tobi)

@scabug
Copy link
Author

scabug commented Sep 15, 2010

@paulp said:
This is a duplicate of #2034 and has also been closed wontfix in #1521. I'm not in with "wontfix", but it is not trivial to fix.

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

No branches or pull requests

1 participant