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

java.lang.AssertionError scaladoc'ing class with a Java annotation #5684

Closed
scabug opened this issue Apr 19, 2012 · 10 comments
Closed

java.lang.AssertionError scaladoc'ing class with a Java annotation #5684

scabug opened this issue Apr 19, 2012 · 10 comments

Comments

@scabug
Copy link

scabug commented Apr 19, 2012

Given a Java annotation:

@retention(RetentionPolicy.RUNTIME)
@target({ElementType.PARAMETER, ElementType.FIELD})
public @interface MyAnnotation {
String value();
}

And a Scala class:

class MyClass(@(MyAnnotation@getter)("foo") var bar: String)

Scaladoc fails w/ java.lang.AssertionError. Last scaladoc-related frame of the stack is ModelFactory$$anon$15.(ModelFactory.scala:461)

@scabug
Copy link
Author

scabug commented Apr 19, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5684?orig=1
Reporter: James Koch (jameskoch)
Affected Versions: 2.10.0-M3, 2.10.0
Attachments:

  • Repro.zip (created on Apr 23, 2012 4:37:20 PM UTC, 12610 bytes)

@scabug
Copy link
Author

scabug commented Apr 19, 2012

@VladUreche said:
Hi James, can you please reduce the testcase so I can run it on my computer? Also, are you using some special plugin, because I can't compile

public @interface MyAnnotation { String value(); }

with javac?

@scabug
Copy link
Author

scabug commented Apr 20, 2012

James Koch (jameskoch) said:
Sorry, I hastily left off several imports. The following compiles w/ javac 1.6.0_29 on OSX:

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.FIELD})
public @interface MyAnnotation { String value(); }

@scabug
Copy link
Author

scabug commented Apr 20, 2012

@VladUreche said:
Thanks Jason! (and Dominik who emailed me the version with the imports)

Can you please also show me the output of {{scaladoc -version}}? I tried reproducing the bug on 2.10 trunk and 2.9.2 and the assertion failure doesn't kick in. Also can you check the classpath is the same as when you're compiling with scalac?

@scabug
Copy link
Author

scabug commented Apr 20, 2012

@VladUreche said:
Jason, can you also paste the complete output of scaladoc? Maybe there are other errors that appear before the assertion failure that can explain the behavior.

@scabug
Copy link
Author

scabug commented Apr 22, 2012

James Koch (jameskoch) said:
The two input files and the verbose scaladoc output are in this archive - https://docs.google.com/open?id=0B0G_SlGP0bOHdXdoMHkxcFdZS1U

These were produced using Scala 2.9.2 on OSX w/ the command line:
scaladoc -verbose -d ./out MyClass.scala MyAnnotation.java

If I compile the Java first and pull it in through the classpath, then scaladoc completes without error. So perhaps this is just user error on my part?

@scabug
Copy link
Author

scabug commented Apr 23, 2012

@VladUreche said:
Thanks for the log! I was able to reproduce it on 2.9.2. I'll let you know what's happening soon.

@scabug
Copy link
Author

scabug commented Apr 23, 2012

@VladUreche said:
Thanks for reporting it James! There's a bug in the java file parser, described in #5699.
Whenever you give scalac or scaladoc a Java file, it parses it and the resulting tree is used in the compiler. Unfortunately the tree is incorrect and this blows up scaladoc.

For the time being, can you compile the java class and put in the classpath?

@scabug
Copy link
Author

scabug commented Apr 23, 2012

@VladUreche said:
The files posted by James on google docs, now attached to the tracker.

@scabug scabug closed this as completed Apr 2, 2013
@scabug
Copy link
Author

scabug commented Apr 2, 2013

@vigdorchik said:
Fixed as a result of fixed #5699

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

No branches or pull requests

2 participants