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

getSimpleClassName and getCanonicalClassName fail on classes defined in the REPL #4118

Closed
scabug opened this issue Dec 28, 2010 · 2 comments
Closed
Assignees

Comments

@scabug
Copy link

scabug commented Dec 28, 2010

=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class Test
defined class Test

scala> val t1 = new Test
t1: Test = Test@20f5e814

scala> t1.getClass.getSimpleName
java.lang.InternalError: Malformed class name
	at java.lang.Class.getSimpleName(Class.java:1133)
	at .<init>(<console>:8)
	at .<clinit>(<console>)
	at RequestResult$$.<init>(<console>:9)
	at RequestResult$$.<clinit>(<console>)
	at RequestResult$$scala_repl_result(<console>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$apply$$17.apply(Interpreter.scala:988)
	at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$apply$$17.apply(Interpreter.scala:988)
	at scala.util.con...

scala> t1.getClass.getCanonicalName
java.lang.InternalError: Malformed class name
	at java.lang.Class.getSimpleName(Class.java:1133)
	at java.lang.Class.getCanonicalName(Class.java:1176)
	at .<init>(<console>:8)
	at .<clinit>(<console>)
	at RequestResult$$.<init>(<console>:9)
	at RequestResult$$.<clinit>(<console>)
	at RequestResult$$scala_repl_result(<console>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$apply$$17.apply(Interpreter.scala:988)
	at scala.tools.nsc.Interpreter$$Request$$$$anonfun$$loadAndRun$$1$$$$anonfun$$ap...

=== What is the expected behavior? ===

The correct names should be returned and no exception thrown.

=== What do you see instead? ===

Exceptions are thrown.

=== Additional information ===

This is most likely related to and possibly a duplicate of #2034. I'm creating a separate ticket because it's not entirely obvious they are duplicates, so if they are are duplicates it will create a clear, easy-to-find record of it.

=== What versions of the following are you using? ===

  • Scala: 2.8.1
  • Java: 1.6.0_22
  • Operating system: OSX 10.5
@scabug
Copy link
Author

scabug commented Dec 28, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4118?orig=1
Reporter: @eengbrec

@scabug
Copy link
Author

scabug commented Dec 28, 2010

@paulp said:
OK, clear easy-to-find record entered into the record. It's definitely a duplicate.

When you enter "class Test" into the repl, the code which is compiled looks like this, which I trust makes the duplicate attribute apparent.

object lineXX$$object {
  object $$iw {
    object $$iw {
      class Test
    }
  }
}

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

2 participants