Example failing with java.lang.InternalError: Malformed class name

457 views
Skip to first unread message

Thomas Sant'ana

unread,
Jul 18, 2010, 8:56:19 PM7/18/10
to specs...@googlegroups.com
Hi,

 I am moving my code base from Scala 2.7.7 to Scala 2.8.0  (specs 1.6.5) and I ran into this:

org.specs.runner.SpecError: java.lang.InternalError: Malformed class name
org.specs.runner.UserError: java.lang.InternalError: Malformed class name
    at java.lang.Class.getSimpleName(Class.java:1133)


I tried calling getSimpleName directly and it does throw the exception. I fear it's a Scala bug, but I was wondering if this is older. I was using version 2.7.7, specs 1.6.2.2-SNAPSHOT, with no problem.

Just wanted to know how best to fix this. I have considered unnesting these classes.

Thomas

---- Sample Spec ----


object Effect {
  abstract class Duration(initDesc: String) {
    def shortDescription = initDesc
    def this() = this (null)
    override def toString() = "Effect.Duration(" + shortDescription + ")"
  }

  object Duration {
    object Fixed extends Duration("Fixed")
    case class Timed(sec:Int) extends Duration {
      override def shortDescription: String = sec.toString + " secs"
    }
  }
}

@RunWith(classOf[JUnitSuiteRunner])
class BadNameTest extends JUnit4(BadNameSpec)

object BadNameSpec extends Specification {

  "bad name " in {
    val dur = Effect.Duration.Timed(30)

    dur must_== dur
  }

  "not a bad name" in {
    val dur = Effect.Duration.Fixed

    dur must_== dur
  }
}

----- Full Stack Trace ----


org.specs.runner.SpecError: java.lang.InternalError: Malformed class name
org.specs.runner.UserError: java.lang.InternalError: Malformed class name
    at java.lang.Class.getSimpleName(Class.java:1133)
    at org.specs.util.Classes$class.className(Classes.scala:162)
    at org.specs.util.Classes$.className(Classes.scala:27)
    at org.specs.util.Classes$class.getClassName(Classes.scala:171)
    at org.specs.util.Classes$.getClassName(Classes.scala:27)
    at org.specs.matcher.AnyBaseMatchers$$anon$2.apply(AnyMatchers.scala:91)
    at org.specs.specification.Expectable.executeMatch$1(Expectable.scala:101)
    at org.specs.specification.Expectable.applyMatcher(Expectable.scala:116)
    at org.specs.specification.Expectation.must(Expectable.scala:172)
    at org.specs.specification.Expectation.must_$eq$eq(Expectable.scala:201)
    at test.BadNameSpec$$anonfun$1.apply(BadNameSpec.scala:53)
    at test.BadNameSpec$$anonfun$1.apply(BadNameSpec.scala:50)
    at org.specs.specification.LifeCycle$class.withCurrent(ExampleLifeCycle.scala:60)
    at org.specs.specification.Examples.withCurrent(Examples.scala:52)
    at org.specs.specification.Examples$$anonfun$specifyExample$1.apply(Examples.scala:111)
    at org.specs.specification.Examples$$anonfun$specifyExample$1.apply(Examples.scala:111)
    at org.specs.specification.ExampleExecution$$anonfun$3$$anonfun$apply$5.apply(ExampleLifeCycle.scala:211)
    at scala.Option.getOrElse(Option.scala:59)
    at org.specs.specification.LifeCycle$class.executeExpectations(ExampleLifeCycle.scala:82)
    at org.specs.specification.BaseSpecification.executeExpectations(BaseSpecification.scala:58)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$class.id$1(ExampleContext.scala:32)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:80)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.ExampleContext$class.executeExpectations(ExampleContext.scala:80)
    at org.specs.specification.Examples.executeExpectations(Examples.scala:52)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anonfun$apply$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$class.id$1(ExampleContext.scala:32)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scala:33)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:81)
    at org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply(ExampleContext.scala:80)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.ExampleContext$class.executeExpectations(ExampleContext.scala:80)
    at org.specs.specification.Examples.executeExpectations(Examples.scala:52)
    at org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle.scala:211)
    at org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle.scala:190)
    at org.specs.specification.ExampleExecution$$anonfun$2.apply(ExampleLifeCycle.scala:173)
    at org.specs.specification.ExampleExecution.execute(ExampleLifeCycle.scala:244)
    at org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.apply(SpecificationExecutor.scala:75)
    at org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.apply(SpecificationExecutor.scala:75)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.SpecificationExecutor$class.executeExample(SpecificationExecutor.scala:75)
    at org.specs.specification.BaseSpecification.executeExample(BaseSpecification.scala:58)
    at org.specs.specification.BaseSpecification.executeExample(BaseSpecification.scala:58)
    at org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(ExampleLifeCycle.scala:117)
    at org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(ExampleLifeCycle.scala:117)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.ExampleLifeCycle$class.executeExample(ExampleLifeCycle.scala:117)
    at org.specs.specification.Examples.executeExample(Examples.scala:52)
    at org.specs.specification.Examples.executeExample(Examples.scala:52)
    at org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples.scala:80)
    at org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples.scala:80)
    at scala.Option.map(Option.scala:74)
    at org.specs.specification.Examples.executeExamples(Examples.scala:80)
    at org.specs.specification.ExampleStructure$class.ownSkipped(ExampleStructure.scala:60)
    at org.specs.specification.Examples.ownSkipped(Examples.scala:52)
    at org.specs.runner.ExampleTestCase.run(JUnit.scala:205)
    at org.specs.runner.JUnitSuite$class.run(JUnit.scala:62)
    at org.specs.runner.JUnit4.run(JUnit.scala:138)
    at org.specs.runner.JUnitSuiteRunner.run(JUnitSuiteRunner.scala:45)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:94)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)



etorreborre

unread,
Jul 18, 2010, 9:21:41 PM7/18/10
to specs-users
Hi Thomas,

This is not a specs issue. I could boil it down to this spec:

object Effect {
object Duration {
class Timed
}
}
class BadNameSpec extends SpecificationWithJUnit {
"bad name " in {
new Effect.Duration.Timed().getClass.getSimpleName
}
}

It could be an effect of the following tickets:

- https://lampsvn.epfl.ch/trac/scala/ticket/2034 (still open but a bit
different)
- or https://lampsvn.epfl.ch/trac/scala/ticket/286 (not quite the same
either)

I would suggest that you open a new ticket referencing the 2 existing
ones which seem to be similar.

Eric.
> org.specs.specification.ExampleExecution$$anonfun$3$$anonfun$apply$5.apply( ExampleLifeCycle.scala:211)
>     at scala.Option.getOrElse(Option.scala:59)
>     at
> org.specs.specification.LifeCycle$class.executeExpectations(ExampleLifeCycl e.scala:82)
>     at
> org.specs.specification.BaseSpecification.executeExpectations(BaseSpecifica tion.scala:58)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3.apply(ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3.apply(ExampleContext.scala:81)
>     at org.specs.specification.ExampleContext$class.id
> $1(ExampleContext.scala:32)
>     at
> org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scal a:33)
>     at
> org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scal a:33)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply (ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply (ExampleContext.scala:80)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.ExampleContext$class.executeExpectations(ExampleCon text.scala:80)
>     at
> org.specs.specification.Examples.executeExpectations(Examples.scala:52)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3$$anonfun$apply$4.apply(ExampleContext.scala:81)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3.apply(ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3$$anon fun$apply$3.apply(ExampleContext.scala:81)
>     at org.specs.specification.ExampleContext$class.id
> $1(ExampleContext.scala:32)
>     at
> org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scal a:33)
>     at
> org.specs.specification.ExampleContext$$anonfun$1.apply(ExampleContext.scal a:33)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply (ExampleContext.scala:81)
>     at
> org.specs.specification.ExampleContext$$anonfun$executeExpectations$3.apply (ExampleContext.scala:80)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.ExampleContext$class.executeExpectations(ExampleCon text.scala:80)
>     at
> org.specs.specification.Examples.executeExpectations(Examples.scala:52)
>     at
> org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle. scala:211)
>     at
> org.specs.specification.ExampleExecution$$anonfun$3.apply(ExampleLifeCycle. scala:190)
>     at
> org.specs.specification.ExampleExecution$$anonfun$2.apply(ExampleLifeCycle. scala:173)
>     at
> org.specs.specification.ExampleExecution.execute(ExampleLifeCycle.scala:244 )
>     at
> org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.app ly(SpecificationExecutor.scala:75)
>     at
> org.specs.specification.SpecificationExecutor$$anonfun$executeExample$3.app ly(SpecificationExecutor.scala:75)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.SpecificationExecutor$class.executeExample(Specific ationExecutor.scala:75)
>     at
> org.specs.specification.BaseSpecification.executeExample(BaseSpecification. scala:58)
>     at
> org.specs.specification.BaseSpecification.executeExample(BaseSpecification. scala:58)
>     at
> org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(Ex ampleLifeCycle.scala:117)
>     at
> org.specs.specification.ExampleLifeCycle$$anonfun$executeExample$1.apply(Ex ampleLifeCycle.scala:117)
>     at scala.Option.map(Option.scala:74)
>     at
> org.specs.specification.ExampleLifeCycle$class.executeExample(ExampleLifeCy cle.scala:117)
>     at org.specs.specification.Examples.executeExample(Examples.scala:52)
>     at org.specs.specification.Examples.executeExample(Examples.scala:52)
>     at
> org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples. scala:80)
>     at
> org.specs.specification.Examples$$anonfun$executeExamples$1.apply(Examples. scala:80)
>     at scala.Option.map(Option.scala:74)
>     at org.specs.specification.Examples.executeExamples(Examples.scala:80)
>     at
> org.specs.specification.ExampleStructure$class.ownSkipped(ExampleStructure. scala:60)
>     at org.specs.specification.Examples.ownSkipped(Examples.scala:52)
>     at org.specs.runner.ExampleTestCase.run(JUnit.scala:205)
>     at org.specs.runner.JUnitSuite$class.run(JUnit.scala:62)
>     at org.specs.runner.JUnit4.run(JUnit.scala:138)
>     at org.specs.runner.JUnitSuiteRunner.run(JUnitSuiteRunner.scala:45)
>     at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
>     at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTest Runner.java:94)
>     at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitSt arter.java:192)
Reply all
Reply to author
Forward
0 new messages