SUGGESTED FIX
Index: j2se/src/share/classes/com/sun/tools/javac/comp/Resolve.java
--- /tmp/geta11070 2006-11-21 15:44:46.000000000 -0800
+++ /tmp/getb11070 2006-11-21 15:44:46.000000000 -0800
@@ -1528,6 +1528,11 @@
* ResolveError classes, indicating error situations when accessing symbols
****************************************************************************/
+ public void logAccessError(Env<AttrContext> env, JCTree tree, Type type) {
+ AccessError error = new AccessError(env, type.getEnclosingType(), type.tsym);
+ error.report(log, tree.pos(), type.getEnclosingType(), null, null, null);
+ }
+
/** Root class for resolve errors.
* Instances of this class indicate "Symbol not found".
* Instances of subclass indicate other errors.
Index: j2se/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
--- /tmp/geta11079 2006-11-21 15:45:16.000000000 -0800
+++ /tmp/getb11079 2006-11-21 15:45:16.000000000 -0800
@@ -52,6 +52,8 @@
private Enter enter;
private boolean allowEnums;
private Types types;
+ private final Resolve resolve;
+
/**
* Flag to indicate whether or not to generate bridge methods.
* For pre-Tiger source there is no need for bridge methods, so it
@@ -71,6 +73,7 @@
addBridges = source.addBridges();
types = Types.instance(context);
make = TreeMaker.instance(context);
+ resolve = Resolve.instance(context);
}
/** A hashtable mapping bridge methods to the methods they override after
@@ -87,6 +90,8 @@
int oldpos = make.pos;
make.at(tree.pos);
if (!types.isSameType(tree.type, target)) {
+ if (!resolve.isAccessible(env, target.tsym))
+ resolve.logAccessError(env, tree, target);
tree = make.TypeCast(make.Type(target), tree).setType(target);
}
make.pos = oldpos;
@@ -721,6 +726,8 @@
* main method
*************************************************************************/
+ private Env<AttrContext> env;
+
void translateClass(ClassSymbol c) {
Type st = types.supertype(c.type);
@@ -728,8 +735,12 @@
if (st.tag == CLASS)
translateClass((ClassSymbol)st.tsym);
- Env<AttrContext> env = enter.typeEnvs.remove(c);
- if (env != null) {
+ Env<AttrContext> myEnv = enter.typeEnvs.remove(c);
+ if (myEnv == null)
+ return;
+ Env<AttrContext> oldEnv = env;
+ try {
+ env = myEnv;
// class has not been translated yet
TreeMaker savedMake = make;
@@ -752,6 +763,8 @@
make = savedMake;
pt = savedPt;
}
+ } finally {
+ env = oldEnv;
}
}
|