mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
forbid access to package local statics via inheritance from another package (IDEA-66493)
This commit is contained in:
@@ -148,7 +148,7 @@ public class JavaResolveUtil {
|
||||
}
|
||||
|
||||
if (!facade.arePackagesTheSame(member, place)) return false;
|
||||
if (modifierList.hasModifierProperty(PsiModifier.STATIC)) return true;
|
||||
//if (modifierList.hasModifierProperty(PsiModifier.STATIC)) return true;
|
||||
// maybe inheritance lead through package local class in other package ?
|
||||
final PsiClass placeClass = getContextClass(place);
|
||||
if (memberClass == null || placeClass == null) return true;
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p1;
|
||||
|
||||
public class A {
|
||||
static int FOO = 0;
|
||||
static void foo(){}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package p1;
|
||||
|
||||
import p2.B;
|
||||
|
||||
public class C extends B {
|
||||
void f(){
|
||||
System.out.println(<error descr="'FOO' is not public in 'p1.A'. Cannot be accessed from outside package">FOO</error>);
|
||||
<error descr="'foo()' is not public in 'p1.A'. Cannot be accessed from outside package">foo</error>();
|
||||
|
||||
System.out.println(A.FOO);
|
||||
A.foo();
|
||||
|
||||
System.out.println(B.<error descr="'FOO' is not public in 'p1.A'. Cannot be accessed from outside package">FOO</error>);
|
||||
B.<error descr="'foo()' is not public in 'p1.A'. Cannot be accessed from outside package">foo</error>();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p2;
|
||||
|
||||
import p1.A;
|
||||
|
||||
public class B extends A {
|
||||
}
|
||||
@@ -105,6 +105,10 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doTest(BASE_PATH + "/accessibleMember/com/red/C.java", BASE_PATH + "/accessibleMember", false, false);
|
||||
}
|
||||
|
||||
public void testStaticPackageLocalMember() throws Exception {
|
||||
doTest(BASE_PATH + "/staticPackageLocalMember/p1/C.java", BASE_PATH + "/staticPackageLocalMember", false, false);
|
||||
}
|
||||
|
||||
public void testOnDemandImportConflict() throws Exception {
|
||||
doTest(BASE_PATH + "/onDemandImportConflict/Outer.java", BASE_PATH + "/onDemandImportConflict", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user