Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.6
-
None
-
Patch
Description
This issue is related to http://jira.codehaus.org/browse/GROOVY-4434.
If an annotation expects a class (not a classname, but a class) as its value, the java stub compiler does not seem to write out the java stub annotation value correctly. Here is some groovy code that shows an example:
<code>
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
@RunWith(SpringJUnit4ClassRunner.class)
class someClass{
...
}
</code>
The @RunWith annotation expects an actual class (not a class name) as its parameter.
In the above mentioned issue, the annotation value is at least expanded to a fully qualified class name. Using the 1.7.6-SNAPSHOT (which includes the patch from GROOVY-4434), I can confirm the classname is expanded. However, this is the output of the java file the stub compiler creates:
<code>
@org.junit.runner.RunWith(value=org.springframework.test.context.junit4.SpringJUnit4ClassRunner)
class someClass{
...
}
</code>
The trouble is that then javac chokes since org.springframework.test.context.junit4.SpringJUnit4ClassRunner is not an actual class reference. Interestingly, groovyc handles this same code just fine, but javac expects the .class suffix to make the class reference explicit. Thus, the generated code does not compile.
I have attached a very simple patch which seems to address this issue. I do not know, however if this might break something else.
Attachments
Attachments
Issue Links
- duplicates
-
GROOVY-4354 Stub Generator does not add .class for classes in annotations
- Closed