scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Scalac intolerant of missing inner class #8243

Closed scabug closed 10 years ago

scabug commented 10 years ago

During a scala REPL session, I get a compiler error:

scala> memoryProxy.insertData("answer", 42) error: while compiling: during phase: typer library version: version 2.10.3 compiler version: version 2.10.3 reconstructed args: -classpath lib/jnaoqi-1.14.5.jar:.

last tree to typer: Ident(memoryProxy) symbol: (flags: ) symbol definition: symbol owners: context owners: value res10 -> object $iw -> object $iw -> object $iw -> object $iw -> object $read -> package $line31

== Enclosing template or block ==

Template( // val <local $iw>: "java.lang.Object" // parents ValDef( private "_"

) // 2 statements DefDef( // def : "" [] List(Nil) Block( Apply( super."" Nil ) () ) ) ValDef( // private[this] val res10: private "res10" Apply( "memoryProxy"."insertData" // 2 arguments "answer" 42 ) ) ) uncaught exception during compilation: java.lang.AssertionError java.lang.AssertionError: com.aldebaran.proxy.Variant$typeV at scala.tools.nsc.symtab.classfile.ClassfileParser$$anonfun$enterOwnInnerClasses$1.apply(ClassfileParser.scala:1120) at scala.tools.nsc.symtab.classfile.ClassfileParser$$anonfun$enterOwnInnerClasses$1.apply(ClassfileParser.scala:1117) at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:107) at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:107) at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:226) at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39) at scala.collection.mutable.HashMap$$anon$2.foreach(HashMap.scala:107) at scala.tools.nsc.symtab.classfile.ClassfileParser.enterOwnInnerClasses(ClassfileParser.scala:1117) at scala.tools.nsc.symtab.classfile.ClassfileParser.parseClass(ClassfileParser.scala:536) .... ... ... I get this error across many library calls, and I can't find a good link between them in terms of method signature. The only link that there is between the functional calls is that they are all proxies generated by Swig, against C++ API. The issue for me is that most API calls work, only some don't.
scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8243?orig=1 Reporter: Quinton Anderson (quintona) Attachments:

scabug commented 10 years ago

@retronym said: I believe that the bytecode of class "com.aldebaran.proxy.Variant" declares that is has an inner class Variant$typeV. The Scala classpath implementation expects to be able to find that on the classpath.

Can you post the output of the following:

% jar -tf jnaoqi-1.14.5.jar | grep Variant
% javap -verbose -classpath jnaoqi-1.14.5.jar com.aldebaran.proxy.Variant

It is possible that scalac is less tolerant of the missing class than javac.

scabug commented 10 years ago

@retronym said: Marking as incomplete pending more details.

scabug commented 10 years ago

Quinton Anderson (quintona) said: Hi,

Thanks for the quick response. Here are the brief outputs, the class details are in a text attachment:

javap -verbose -classpath jnaoqi-1.14.5.jar com.aldebaran.proxy.Variant > variantDetails.txt l10001281:lib quintonanderson$ jar -tf jnaoqi-1.14.5.jar | grep Variant com/aldebaran/proxy/Variant.class

scabug commented 10 years ago

Quinton Anderson (quintona) said: Output from javap -verbose -classpath jnaoqi-1.14.5.jar com.aldebaran.proxy.Variant

scabug commented 10 years ago

Quinton Anderson (quintona) said: Added the required details. Thanks again.

scabug commented 10 years ago

@retronym said (edited on Feb 7, 2014 8:03:32 AM UTC): Yep, its as I suspected:

public class com.aldebaran.proxy.Variant
  SourceFile: "Variant.java"
  InnerClasses:
       public static final #44= #43 of #31; //typeV=class com/aldebaran/proxy/Variant$typeV of class com/aldebaran/proxy/Variant
  minor version: 0

Not sure why Variant$typeV is missing from that JAR. I've googled around for similar problems with SWIG, but nothing obvious appears. Maybe you could check on a SWIG mailing list?

How does this work with javac? As a workaround, you could create a Java wrapper class manually for Variant, and refer to that from Scala. So long as scalac never needs to load Variant.class, you will be able to compile.

I'll leave this open pending a report of how javac works. Maybe we can demote the error to a warning.

scabug commented 10 years ago

Quinton Anderson (quintona) said: Thanks for the help. I am also not sure why the inner class was missing, I have managed to rebuild the Swig layer and now have a working jar.

I think you should leave it as an error, it was valid. Thanks.