@Configuration("configuration")
class SpringConfiguration {
@Bean(autowire = Autowire.BY_TYPE)
def springContext = Spring
}
object Spring extends ApplicationContextAware with DisposableBean {... etc ...private val _locale = new ThreadLocal[Locale] {override def initialValue(): Locale = defaultLocale
}... etc ...}
An annotation processor threw an uncaught exception. Consult the following stack trace for details. java.lang.NullPointerException at com.sun.tools.javac.jvm.Code.width(Code.java:262) at com.sun.tools.javac.jvm.ClassReader.readMemberAttr(ClassReader.java:880) at com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1027) at com.sun.tools.javac.jvm.ClassReader.readCode(ClassReader.java:1080) at com.sun.tools.javac.jvm.ClassReader.readMemberAttr(ClassReader.java:834) at com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1027) at com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:1490) at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1586) at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:1658) at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1845) at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777) at com.sun.tools.javac.code.Symbol.complete(Symbol.java:384) at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:766) at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:698) at com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements(Symbol.java:525) at javax.lang.model.util.ElementScanner6.visitPackage(ElementScanner6.java:141) at com.sun.tools.javac.code.Symbol$PackageSymbol.accept(Symbol.java:630) at com.sun.tools.javac.processing.JavacRoundEnvironment$AnnotationSetScanner.scan(JavacRoundEnvironment.java:139) at com.sun.tools.javac.processing.JavacRoundEnvironment$AnnotationSetScanner.scan(JavacRoundEnvironment.java:122) at com.sun.tools.javac.processing.JavacRoundEnvironment.getElementsAnnotatedWith(JavacRoundEnvironment.java:116) at org.hibernate.validator.ap.ConstraintValidationProcessor.process(ConstraintValidationProcessor.java:117)
The annotation processor is configured as follows :
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
<execution>
<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>generate-test-sources</phase>
</execution>
</executions>
<configuration>
<detail>true</detail>
<options>
<verbose>true</verbose>
<diagnosticKind>NOTE</diagnosticKind>
</options>
<outputDiagnostics>true</outputDiagnostics>
</configuration>
</plugin>
Apparently the origin of the NPE can be traced back to the override of the threadlocal variable _locale. If the override is removed it all works. private val _locale = new ThreadLocal[Locale] {override def initialValue(): Locale = defaultLocale
}Replaced byprivate val _locale = new ThreadLocal[Locale]
val resourceKeys: String = {
val properties = new Properties
val is = getClass.getClassLoader.getResourceAsStream("bundles/labels.properties")
properties.load(is)
properties.keys.asScala.map(_.toString).toSeq.sorted.mkString(" ")
}
Works when replaced by:
def resourceKeys: String = {
val properties = new Properties
val is = getClass.getClassLoader.getResourceAsStream("bundles/labels.properties")
properties.load(is)
properties.keys.asScala.map(_.toString).toSeq.sorted.mkString(" ")
}
Yet another case. It seems the annotation processor plugin can't cope with vals having an initializer expression.Is there really nobody who has a clue about the problem ?
Could you either try to modify that project (by trying different Scala constructs in sample.ScalaClass
) to see if you can reproduce the error? Alternatively, could you create a standalone test project using the that Maven plugin to trigger the error?
From a quick look at the OpenJDK code, the stack trace suggests that a class file contains a LocalVariableTable attribute (used to store variable names for debuggers) in a part of the class file where it doesn’t make sense. You could try adding -g:none
to the Scala compiler options to disable that part of the classfile writing to test this theory.
I notice that that NetBeans has a fork of the JDK code that throws this NPE, and in that fork they have hardened against the null parameter type list.
+32 (0)16 317 040 phone
+32 (0)16 317 048 fax
jan.go...@noesissolutions.com
www.noesissolutions.com
===============================================================