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

Invalid compilation error in mixed Scala/Java projects that use Java annotations with default values #3415

Closed
scabug opened this issue May 10, 2010 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented May 10, 2010

This bug was introduced in Scala 2.8.0RC2. In a Scala project if we define a Java annotation with default values and try to compile we get the following message: "not found: type root".

An annotation like the following produces the above compilation error

public @interface MyAnnotation {

  String name() default "spiros";
}

This bug is really important since the only reason a Scala programmer has to write Java is for defining annotations. Many of the mixed Scala/Java projects contain annotations and this bug prevents any development in those projects.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 10, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3415?orig=1
Reporter: spiros
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 10, 2010

@milessabin said:
Duplicate of SI-3398? Or can you reproduce this on the command line without -Ybuild-debug:refined?

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 10, 2010

spiros said:
It might be a duplicate but I can reproduce this using maven which compiles everything so I don't believe that it uses the refined build manager.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 10, 2010

spiros said:
I can reproduce this from the command line.

It might be related to the default argument changes that happen recently in trunk r21794.

Given the Java annotation

package hello;

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Documented
@Inherited
public @interface Hello {
  String msg() default "hello world";
}

and the Scala class:

package hello

class HelloWorld {
  @Hello
  def method() { }
}

when I try to compile from the command line using the command scalac hello/* I get the following message:

hello/Hello.java:10: error: not found: type _root_
  String msg() default "hello world";
         ^
hello/HelloWorld.scala:4: error: annotation hello.Hello is missing argument msg
  @Hello
   ^
two errors found
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 10, 2010

@lrytz said:
(In r21891) close #3415. relates to r21680. review by milessabin.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 11, 2010

@milessabin said:
This also appears to have fixed #3398.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 11, 2010

spiros said:
Great news!

Thanks for the quick fix!

@scabug scabug closed this May 18, 2011
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Nov 1, 2011

Commit Message Bot (anonymous) said:
(extempore in r25923) Fix for #3415 regression.

Now there's an unlikely fix. No review.

@scabug scabug added this to the 2.8.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.