Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
Created June 24, 2013 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuwei-k/5849572 to your computer and use it in GitHub Desktop.
Save xuwei-k/5849572 to your computer and use it in GitHub Desktop.
SI-7439 ?
  1. publish-local a
  2. compile c

maybe? SI-7439

// a/src/main/java/A.java
package com.example;
public @interface A{}
// b/src/main/scala/B.scala
@com.example.A
class B
sbt.version=0.13.0-Beta2
lazy val baseSettings = seq(
resolvers += Opts.resolver.sonatypeSnapshots,
scalaVersion := "2.10.2"
)
baseSettings
lazy val a = project.settings(
organization := "com.example",
name := "a",
version := "0.1-SNAPSHOT",
autoScalaLibrary := false,
crossPaths := false
).settings(baseSettings: _*)
lazy val b = project.settings(baseSettings: _*).settings(
libraryDependencies += "com.example" % "a" % "0.1-SNAPSHOT" % "optional"
)
lazy val c = project.dependsOn(b).settings(baseSettings: _*)
// c/src/main/scala/C.scala
object C extends App{
println(new B())
}
[info] Compiling 1 Scala source to /Users/user/java-annotation-bug/c/target/scala-2.10/classes...
[warn] Class com.example.A not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in /Users/user/java-annotation-bug/b/target/scala-2.10/classes/B.class
[warn] Caught: java.lang.RuntimeException: bad constant pool index: 0 at pos: 483 while parsing annotations in /Users/user/java-annotation-bug/b/target/scala-2.10/classes/B.class
[error] error while loading B, class file '/Users/user/java-annotation-bug/b/target/scala-2.10/classes/B.class' is broken
[error] (class java.lang.RuntimeException/Scala class file does not contain Scala annotation)
[error] /Users/user/java-annotation-bug/c/src/main/scala/C.scala:3: B does not have a constructor
[error] println(new B())
[error] ^
[warn] three warnings found
[error] two errors found
[error] (c/compile:compile) Compilation failed
@retronym
Copy link

Here's the output after the fix for SI-7439.

[warn] Class com.example.A not found - continuing with a stub.
[error] error while loading B, Missing dependency 'bad symbolic reference. A signature in B.class refers to term example
[error] in package com which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling B.class.', required by /Users/jason/code/gist/npe-5849572/b/target/scala-2.10/classes/B.class
[warn] one warning found
[error] one error found
[error] (c/compile:compile) Compilation failed
[error] Total time: 14 s, completed Jun 24, 2013 3:24:27 PM

No mention of the NullPointerException or the bad constant pool index, but something is still forcing the stub symbol. I'll take a further look.

Thanks for the great test case!

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