- do not set 'outer class' property when parsing classes using inner classes declared elsewhere;

- for inner classes store complete set of access flags
This commit is contained in:
Eugene Zhuravlev
2017-10-31 16:38:22 +03:00
parent eeb07a830a
commit 6871c142ba
10 changed files with 63 additions and 7 deletions
@@ -7,7 +7,9 @@ src/A.java
End of files
Cleaning output files:
out/production/AddStatic/B.class
out/production/AddStatic/C.class
End of files
Compiling files:
src/B.java
End of files
src/C.java
End of files
@@ -0,0 +1,16 @@
Cleaning output files:
out/production/ChangeInnerClassModifiers/A$Inner1.class
out/production/ChangeInnerClassModifiers/A$Inner2.class
out/production/ChangeInnerClassModifiers/A.class
End of files
Compiling files:
src/A.java
End of files
Cleaning output files:
out/production/ChangeInnerClassModifiers/B.class
out/production/ChangeInnerClassModifiers/C.class
End of files
Compiling files:
src/B.java
src/C.java
End of files
@@ -0,0 +1,7 @@
public class A {
public static class Inner1 {
}
public class Inner2 {
}
}
@@ -0,0 +1,7 @@
public class A {
public class Inner1 {
}
public abstract class Inner2 {
}
}
@@ -0,0 +1,3 @@
public class B {
void perform(A.Inner1 param) {}
}
@@ -0,0 +1,3 @@
public class C {
void perform(A.Inner2 param) {}
}
@@ -7,7 +7,9 @@ src/A.java
End of files
Cleaning output files:
out/production/RemoveStatic/B.class
out/production/RemoveStatic/C.class
End of files
Compiling files:
src/B.java
End of files
src/C.java
End of files
@@ -742,11 +742,16 @@ class ClassfileAnalyzer {
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
if (outerName != null) {
myOuterClassName.set(outerName);
}
if (innerName == null) {
myAnonymousClassFlag.set(true);
if (myContext.get(name) == myName) {
// set outer class name only if we are parsing the real inner class and
// not the reference to inner class inside some top-level class
myAccess |= access; // information about some access flags for the inner class is missing from the mask passed to 'visit' method
if (outerName != null) {
myOuterClassName.set(outerName);
}
if (innerName == null) {
myAnonymousClassFlag.set(true);
}
}
}
@@ -1935,6 +1935,13 @@ public class Mappings {
state.myAffectedUsages.add(UsageRepr.createClassNewUsage(myContext, changedClass.name));
}
if (!changedClass.isAnonymous() && !isEmpty(changedClass.getOuterClassName()) && !changedClass.isPrivate()) {
if (addedModifiers != 0 || diff.removedModifiers() != 0) {
debug("Some modifiers (access flags) were changed for non-private inner class, adding class usage to affected usages");
state.myAffectedUsages.add(changedClass.createUsage());
}
}
if (changedClass.isAnnotation()) {
debug("Class is annotation, performing annotation-specific analysis");
@@ -51,4 +51,8 @@ public class ClassModifierTest extends IncrementalTestCase {
public void testSetFinal1() {
doTest();
}
public void testChangeInnerClassModifiers() {
doTest();
}
}