Annotation reference to Java interface constants failing comp in Intellij but not maven

I have a Scala class that that has an annotation @A that takes an id. I want the id to come from a Java interface containing some constants, for example:


The problem is that with compiler 2.8.1, IntelliJ fails the compilation saying:

error: annotation argument needs to be a constant; found: Ids.SERVER_CACHE_VALUE

However, when I run the compilation from command line (we use maven), it compiles without any problems.

I've imported the project from maven, where we define the 2.8.1 scala compiler requirement, and in IntellijX EAP (98.402 and Scala plugin 0.4.207), it seems to use that Scala compiler (module settings say so), but maybe something is wrong in the integration?

By the way, the problem occurrs with Intellij IDEA 9.0.4 and Scala plugin 0.3.2093

1 comment
Comment actions Permalink

This sounds like The bug only shows up when scalac processes the Java code as  as a .java file (source), rather than as a .class file (compiled bytecode).

1) if you don't call .scala code from .java files within a module, uncheck 'Compile Scala files first' under Settings -> Compiler -> Scala Compiler
2) Move the Java annotations to a separate module, and depend on that module from the module containing your Scala code

#2 is probably the safest and simplest.



Please sign in to leave a comment.