|
|
|
[
Permlink
| « Hide
]
Philip Milne - 25/Feb/08 03:44 AM
I probably should have used a higher priorty when reporting this since it turned out to be a showstopper for us. We subsequently found some more bugs - all of which seem to point to problems in the way that Janino does name resolution across multiple files. For now we have cut over to the 1.6 compiler API but we would like to use Janino so we can deploy to JREs - so would be interested in any comments you have. If you'd like to contact me directly I'm at philip<at>pmilne<dot>net.
If you apply this patch
### Eclipse Workspace Patch 1.0
#P janino
Index: src/org/codehaus/janino/UnitCompiler.java
===================================================================
RCS file: /home/projects/janino/scm/janino/src/org/codehaus/janino/UnitCompiler.java,v
retrieving revision 1.56
diff -u -r1.56 UnitCompiler.java
--- src/org/codehaus/janino/UnitCompiler.java 25 Dec 2007 22:17:12 -0000 1.56
+++ src/org/codehaus/janino/UnitCompiler.java 26 Feb 2008 22:17:25 -0000
@@ -5292,7 +5292,11 @@
// JLS3 6.5.2.BL1.B1.B2.1 Static field imported through single static import.
{
Object o = this.singleStaticImports.get(identifier);
- if (o instanceof IField) return new FieldAccess(location, new SimpleType(location, ((IField) o).getDeclaringIClass()), (IField) o);
+ if (o instanceof IField) {
+ FieldAccess fieldAccess = new FieldAccess(location, new SimpleType(location, ((IField) o).getDeclaringIClass()), (IField) o);
+ fieldAccess.setEnclosingBlockStatement(enclosingBlockStatement);
+ return fieldAccess;
+ }
}
// JLS3 6.5.2.BL1.B1.B2.2 Static field imported through static-import-on-demand.
@@ -5301,7 +5305,11 @@
IField[] flds = iClass.getDeclaredIFields();
for (int i = 0 ; i < flds.length; ++i) {
IField f = flds[i];
- if (f.getName().equals(identifier)) return new FieldAccess(location, new SimpleType(location, iClass), f);
+ if (f.getName().equals(identifier)) {
+ FieldAccess fieldAccess = new FieldAccess(location, new SimpleType(location, iClass), f);
+ fieldAccess.setEnclosingBlockStatement(enclosingBlockStatement);
+ return fieldAccess;
+ }
}
}
, then you get c:\tmp\testsrc\b\C3.java, Line 8, Column 27: Private member cannot be accessed from type "b.C3"." , which is right according to the JLS3. Is that the behavior that you expect, too? CU Arno Many thanks for taking a look. Its been a while but no, I don't think so. Javacc seems to compile
all three classes wihtout error as field A is inaccessible from class C2 but accessbile from C1. Regards, Philip Yep, you may be right. JLS3 "7.5.4 Static-Import-on-Demand Declaration" says:
Fixed UnitCompiler accordingly; updated the JUnit suite. Please test with version 2.5.13. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||