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

NoSuchElementException in ClassFileParser for Java inner classes referring to outer parameters #9152

Open
scabug opened this issue Feb 16, 2015 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 16, 2015

% tail test/files/run/som/*.{java,scala}
==> test/files/run/som/Java_1.java <==

public class Java_1<K, V> {
    public class Inner extends Java_1<K, V> {

    }
}

class SomeOtherJava {

}
==> test/files/run/som/Macros_1.scala <==
  def fImpl(c: Context): c.Tree = {
    import c.universe._
    import reflect.runtime.{universe => ru}

    val formatterSym = c.universe.symbolOf[bakery.SomeOtherJava]
    ru.internal.createImporter(c.universe).importSymbol(formatterSym)

    q"()"
  }
}

==> test/files/run/som/Test_2.scala <==
object Test {
  bakery.Bakery.f
}

% javac -d /tmp test/files/run/som/*.java && qscalac -classpath /tmp -d /tmp test/files/run/som/Macros_1.scala && qscalac -classpath /tmp -d /tmp test/files/run/som/Test_2.scala
error: error while loading Java_1$Inner, class file '/tmp/bakery/Java_1$Inner.class' is broken
(class java.util.NoSuchElementException/key not found: K)
one error found
% tail sandbox/{Java_1.java,test.scala}
==> sandbox/Java_1.java <==
public class Java_1<K, V> {
    public class Inner extends Java_1<K, V> {
    }
}

==> sandbox/test.scala <==
object Test {
  classOf[Java_1$Inner]
}

% javac -d /tmp sandbox/Java_1.java && qscalac -classpath /tmp sandbox/test.scala
error: error while loading Java_1$Inner, class file '/tmp/Java_1$Inner.class' is broken
(class java.util.NoSuchElementException/key not found: K)
sandbox/test.scala:2: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
  classOf[Java_1$Inner]
         ^
one warning found
one error found

As reported and discussed https://groups.google.com/d/msg/scala-internals/p3LUQSniAl8/2GB1ok9SK2MJ

@scabug
Copy link
Author

scabug commented Feb 16, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9152?orig=1
Reporter: @retronym
Affected Versions: 2.11.5

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue
Copy link
Member

remains reproducible on 2.12.4

@SethTisue
Copy link
Member

SethTisue commented Dec 6, 2017

perhaps a .hasCompleteInfo check is missing somewhere? I hit this error in a closed-source compiler plugin, in reference to Hashtable.Entry in the Java stdlib. Adding such a check (as suggested by @adriaanm) fixed it.

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

3 participants