Skip to content
Permalink
Browse files

8249829: javac is issuing an incorrect static access error

Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Jul 27, 2020
1 parent af8c3b4 commit 6c2ff1781b0213e987706ee8a8ab92e19f5177f4
@@ -2289,13 +2289,11 @@ Symbol findTypeVar(Env<AttrContext> currentEnv, Env<AttrContext> originalEnv, Na
}

boolean isInnerClassOfMethod(Symbol msym, Symbol csym) {
if (csym.owner == msym && !csym.isStatic()) {
return true;
} else if (csym.owner.kind == TYP) {
return isInnerClassOfMethod(msym, csym.owner);
} else {
return false;
while (csym.owner != msym) {
if (csym.isStatic()) return false;
csym = csym.owner.enclClass();
}
return (csym.owner == msym && !csym.isStatic());
}

/** Find an unqualified type symbol.
@@ -800,6 +800,48 @@ void m() {
}
"""
);

// positive cases
assertOK(
"""
import java.security.*;
class Test {
static Test newInstance(Object provider) {
return new Test() {
private final PrivilegedExceptionAction<KeyStore> action = new PrivilegedExceptionAction<KeyStore>() {
public KeyStore run() throws Exception {
if (provider == null) {}
return null;
}
};
};
}
}
"""
);

assertOK(
"""
import java.security.*;
class Test {
static Test newInstance(Object provider) {
return new Test() {
int m(PrivilegedExceptionAction<KeyStore> a) { return 0; }
{
m(
new PrivilegedExceptionAction<KeyStore>() {
public KeyStore run() throws Exception {
if (provider == null) {}
return null;
}
}
);
}
};
}
}
"""
);
}

public void testReturnInCanonical_Compact() {

0 comments on commit 6c2ff17

Please sign in to comment.