Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8249829: javac is issuing an incorrect static access error
Browse files Browse the repository at this point in the history
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Jul 27, 2020
1 parent 6a91c51 commit bd00604
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
42 changes: 42 additions & 0 deletions test/langtools/tools/javac/records/RecordCompilationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,48 @@ static record RR(int x) { };
}
"""
);

// 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() {
Expand Down

0 comments on commit bd00604

Please sign in to comment.