diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java
new file mode 100644
index 000000000000..986e6f391d9b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AbstractMethods.java
@@ -0,0 +1,109 @@
+// abstract methods
+public class a {
+ void f();
+
+}
+abstract class c1 {
+ abstract void f1();
+ int f2();
+}
+
+interface ff {
+ abstract void f1();
+ void f2();
+}
+
+class x {
+ void f() {
+ RuntimeException();
+ throw RuntimeException();
+ }
+}
+
+// -------------------------------------------------------------
+class c2 {
+ abstract void f();
+}
+
+class c3 extends c4 {
+
+}
+
+abstract class c4 {
+ abstract void iif();
+}
+
+class c5 extends c6 implements i7 { public void ff(){} }
+abstract class c6 {}
+interface i7 { void ff(); }
+
+class c7 implements i7 {
+}
+
+class callabstract extends c4 {
+ void iif() {
+ super.iif();
+ }
+}
+
+
+abstract class c8 {
+ public abstract boolean equals(Object other);
+}
+
+final class c9 extends c8 {
+}
+
+
+
+//------- if only Bottom were in other package, it should have been abstract --------------------------
+public abstract class AbstractTest {
+
+ abstract String getName();
+
+ abstract static class Middle extends AbstractTest {
+
+ }
+
+ static class Bottom extends Middle {
+ String getName() {
+ return null;
+ }
+ }
+}
+
+///////////
+abstract class cc1 {
+ abstract void f(int i);
+}
+abstract class cc2 extends cc1 {
+ abstract protected void f(int i);
+}
+class cc3 extends cc2 {
+ public void f(int i) {}
+}
+///////////////
+interface MyComparator {
+ int compare(Object t, Object t1);
+
+ boolean equals(java.lang.Object object);
+}
+class MyComparatorImpl implements MyComparator {
+ public int compare(Object o, Object o1) {
+ new MyComparator() {
+ public int compare(Object o, Object o1) {
+ return 0;
+ }
+ };
+ return 0;
+ }
+}
+//////////////// IDEADEV-6050
+interface Comparable {}
+
+interface PublicCloneable extends Cloneable {
+ Object clone() throws CloneNotSupportedException;
+}
+
+interface PublicCloneableExtension extends Comparable, PublicCloneable {
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java
new file mode 100644
index 000000000000..7fa62b8aa01e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java
@@ -0,0 +1,87 @@
+// access level clashes
+interface i {
+ void ff();
+}
+
+public class a implements i {
+ void ff() {}
+}
+class ai implements i {
+ public int ff() { return 0;}
+}
+
+class c2 implements i {
+ public c2() {}
+ public void ff() {}
+ protected void g() {}
+ private int fff(String s) { return 0; }
+}
+
+class c3 extends c2 {
+ protected c3() {}
+ private int g(int k) { return 2;}
+ private char fff(String s) { return 0; }
+}
+
+class c4 extends c3 {
+ private c4() {}
+ private void g() {}
+ private String fff(String s) throws java.io.IOException { return null; }
+}
+class c4i extends c3 {
+ protected Object g() {return null;}
+}
+
+// sibling inheritance
+abstract class c5 { abstract public int ff(); }
+interface i5 { void ff(); }
+abstract class c6 extends c5 implements i5 {
+}
+
+class c7 { public String ff() { return null;} }
+class c8 extends c7 implements i5 {
+}
+
+// interface should not clash with Object
+interface A {
+ Object clone() throws CloneNotSupportedException;
+ void finalize();
+
+ void hashCode();
+ void equals(Object o);
+ void toString();
+}
+
+interface ConflictWithObject {
+ Object clone() throws CloneNotSupportedException;
+}
+class s implements ConflictWithObject {
+
+}
+
+// parallel overriding methods from Object
+interface InderFace {
+ Object clone() throws CloneNotSupportedException;
+}
+
+interface SubInderFace extends InderFace {
+}
+
+class Implementation implements SubInderFace {
+}
+
+
+
+//SCR20002
+abstract class SCR20002A extends Object implements Runnable {
+ protected abstract int getSome();
+ private final Inner getInner() { return null; }
+ private class Inner { }
+}
+
+abstract class SCR20002B extends SCR20002A implements Runnable {
+ private final Inner getInner() { return null; }
+ private class Inner { }
+}
+abstract class SCR20002C extends SCR20002B implements Runnable {
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AmbiguousMethodCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AmbiguousMethodCall.java
new file mode 100644
index 000000000000..4155ee049f7b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AmbiguousMethodCall.java
@@ -0,0 +1,35 @@
+// Ambiguous method call
+
+class C61 {
+ public void foo(String s) {}
+ public void foo(Integer i) {}
+ public void foo2() {
+ foo(null);
+ }
+}
+
+class D61 extends C61 {
+ public void foo(Integer i) {}
+ public void foo2() {
+ foo(null);
+ foo(1);
+ }
+}
+class ex {
+ void f(String name, String[] i){}
+ void f(String name, ex i){}
+
+ void g() {
+ f("",null);
+ }
+}
+
+class XX {
+ XX() {}
+ void XX() {}
+
+ {
+ new XX().XX();
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonBaseRef.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonBaseRef.java
new file mode 100644
index 000000000000..bef2526fc89e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonBaseRef.java
@@ -0,0 +1,11 @@
+class A{
+ {
+ class Local{
+ void foo(){}
+ }
+
+ new Local(){
+ void foo(){}
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java
new file mode 100644
index 000000000000..298668e4a615
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AnonInAnon.java
@@ -0,0 +1,21 @@
+public class QQQ {
+ {
+ new Outer(){
+ void foo(){
+ new Inner(){
+ void method() {
+ super.method();
+ }
+ };
+ }
+ };
+ }
+}
+
+class Outer{
+ class Inner{
+ void method(){
+
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java
new file mode 100644
index 000000000000..2049abc9a56b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AssignToFinal.java
@@ -0,0 +1,72 @@
+// assign to final
+import java.io.*;
+import java.net.*;
+public class a21 {
+ final int fi;
+ {
+ fi = 4;
+ }
+ void f1(int i) {
+ final int j = 4;
+ j = 3;
+
+ }
+ void f2(final int i) {
+ final int j = 4;
+ i = 3;
+
+ }
+ void f3( int ip) {
+ fi = 3;
+ for (final int i = 0; i<3; i++) {
+ int k = 4;
+ }
+ final int i1 = 0;
+ i1++;
+ --i1;
+ int i2 = -i1 + ~i1;
+ final int j = (j=0) == 1 || j==0 ? 9 : j;
+ }
+
+ static final boolean DEBUG = false;
+ void f4() {
+ if (DEBUG && (fi < 3 || fi >4)) return;
+ }
+}
+class B extends a21 {
+ public B() {
+ fi = 0;
+ }
+ void f() {
+ final Integer i;
+ new Runnable() {
+ public void run() {
+ i = new Integer(4);
+ }
+ };
+ }
+}
+
+class a21_2 {
+ final int i;
+ a21_2() {
+ i = 0;
+ new Runnable() {
+ public void run() {
+ i = 0;
+ }
+ };
+ }
+}
+
+class Foo {
+ private final Foo next;
+
+ public Foo(Foo previous) {
+ this.next = null;
+
+ if (previous != null) {
+ previous.next = this;
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/BreakOutside.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/BreakOutside.java
new file mode 100644
index 000000000000..f2fd05be2786
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/BreakOutside.java
@@ -0,0 +1,50 @@
+// break outside of
+public class a {
+
+ void f() {
+ break;
+ while (true) {
+ break;
+ }
+ do { break; } while (true);
+ switch (1) {
+ case 1: break;
+ }
+ for (;;) {
+ break;
+ }
+
+ for (;;) {
+ new ff() {
+ void f() {
+ break;
+ }
+ };
+ break;
+ }
+
+
+ while (true) {
+ class s {
+ {
+ break;
+ }
+ }
+ break;
+ }
+
+ do {
+ class s {
+ {
+ break;
+ }
+ }
+ break;
+ } while (true);
+
+ }
+}
+
+class ff {
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CanHaveBody.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CanHaveBody.java
new file mode 100644
index 000000000000..cdb7d19fdd21
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CanHaveBody.java
@@ -0,0 +1,16 @@
+abstract public class a1 {
+ abstract void f() {}
+ native void ff() {}
+
+ void f2() {
+ new ii() {
+ public int iif(int i) {
+ return 0;
+ }
+ };
+ }
+}
+
+interface ii {
+ int iif(int i) throws Exception { return 2; }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CastFromVoid.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CastFromVoid.java
new file mode 100644
index 000000000000..49ea9c93f1da
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CastFromVoid.java
@@ -0,0 +1,8 @@
+class K {
+ public K foo() {
+ return (K) bar();
+ }
+
+ private void bar() {
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CatchUnknownMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CatchUnknownMethod.java
new file mode 100644
index 000000000000..da90b8b2e68b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CatchUnknownMethod.java
@@ -0,0 +1,11 @@
+public class MyClass {
+
+ public static void main(String[] args) {
+ try {
+ unknownMethod(); /* Red code - as expected */
+ } catch (java.io.IOException e) { /* Unwanted red squiggly line */
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ComputeConstant.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ComputeConstant.java
new file mode 100644
index 000000000000..43a794dc58d9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ComputeConstant.java
@@ -0,0 +1,20 @@
+class A_CR{
+ public static final int CONST = CONSTX;
+
+ {
+ switch(0){
+ case CONST:
+ }
+ }
+}
+
+class AClass {
+ private static final String SPACE = " ";
+ class s {
+ private static final String RET_VAL =
+ "Roger" +
+ SPACE +
+ SPACE + // comment and uncomment this line
+ " Dodger";
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java
new file mode 100644
index 000000000000..53059fbdc06b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/CtrCallIsFirst.java
@@ -0,0 +1,63 @@
+// call to super must be first
+public class a {
+ a() {}
+ a(int i) {}
+}
+
+class b extends a {
+ b() {
+ int i = 3;
+ super();
+ }
+ b(int i) {
+ this();
+ super(2);
+ }
+ b(char i) {
+ super(4);
+ this();
+ }
+
+ b(String s) {
+ try {
+ super(2);
+ }
+ finally {
+ }
+ }
+ b(String s, int i) {
+ {
+ super(2);
+ }
+ }
+
+ void f() {
+ super();
+ }
+ void g() {
+ this();
+ }
+
+}
+class O extends A.B
+{
+ public O(A a)
+ {
+ int i = 0;
+ a.super();
+ }
+ public O(A a,int i)
+ {
+ a.super();
+ i = 0;
+ }
+}
+
+class A
+{
+ class B
+ {
+ class C{}
+ }
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Deprecated.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Deprecated.java
new file mode 100644
index 000000000000..ef2978975183
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Deprecated.java
@@ -0,0 +1,62 @@
+// deprecated
+
+class a {
+ /**
+ * @deprecated
+ */
+ void f() {}
+
+ /**
+ * @deprecated
+ */
+ int dep;
+ int notdep;
+
+ /**
+ * @deprecated
+ */
+ a(int i,int j,int k) {
+ new a(k+i+j,dep,notdep);
+ }
+}
+
+class b extends a {
+ void f() {
+ super.f();
+ }
+
+ b() {
+ this(1);
+ }
+
+ /**
+ * @deprecated
+ */
+ b(int i) {
+ super(0,0,i);
+ System.out.print(i);
+ }
+}
+
+class c extends b {
+ // b.f is not deprecated
+ void f() {}
+}
+
+interface i1 {
+ /**
+ * @deprecated
+ */
+ void f();
+}
+abstract class ac1 {
+ /**
+ * @deprecated
+ */
+ public abstract void f();
+}
+
+class ci1 extends ac1 implements i1 {
+ // no chance not to implement it
+ public void f() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DotBeforeDecl.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DotBeforeDecl.java
new file mode 100644
index 000000000000..058b40565ab4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DotBeforeDecl.java
@@ -0,0 +1,7 @@
+public class A_DBD {
+ {
+ int field = 0;
+ field.
+ String s = null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethod.java
new file mode 100644
index 000000000000..6908ad8db5dc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethod.java
@@ -0,0 +1,75 @@
+public class a {
+ void f(int i) { }
+ void f(int i) {
+
+ new c1() {
+ public void f1() {}
+ public void f1() {}
+ };
+ }
+}
+abstract class c1 {
+ abstract void f1();
+}
+
+interface ii {
+ abstract void f1();
+ void f2();
+}
+
+class a {
+}
+
+class Foo {
+ void f() {
+ class Bar {
+ }
+ class Bar {
+ }
+ }
+}
+
+
+class c2 {
+ class c3 {
+ void f() {
+ class c2 {
+ }
+ }
+ }
+}
+
+
+class cont {
+ class B {
+ }
+ {
+ class B {
+ }
+ }
+ class B {
+ }
+}
+class cont2 {
+ {
+ class B {
+ }
+ }
+ class B {
+ }
+}
+class ok {
+ class Local{};
+ class AnotherLocal {
+ class Local {};
+ void bar() {
+ class Local {};
+ Local l;
+ }
+ }
+}
+
+class ok2 {
+ public ok2() {}
+ public void ok2() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethodTop.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethodTop.java
new file mode 100644
index 000000000000..642e3501231b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateClassMethodTop.java
@@ -0,0 +1,75 @@
+public class a {
+ void f(int i) { }
+ void f(int i) {
+
+ new c1() {
+ public void f1() {}
+ public void f1() {}
+ };
+ }
+}
+abstract class c1 {
+ abstract void f1();
+}
+
+interface ii {
+ abstract void f1();
+ void f2();
+}
+
+class a {
+}
+
+class Foo {
+ void f() {
+ class Bar {
+ }
+ class Bar {
+ }
+ }
+}
+
+
+class c2 {
+ class c3 {
+ void f() {
+ class c2 {
+ }
+ }
+ }
+}
+
+
+class cont {
+ class B {
+ }
+ {
+ class B {
+ }
+ }
+ class B {
+ }
+}
+class cont2 {
+ {
+ class B {
+ }
+ }
+ class B {
+ }
+}
+class ok {
+ class Local{};
+ class AnotherLocal {
+ class Local {};
+ void bar() {
+ class Local {};
+ Local l;
+ }
+ }
+}
+
+class ok2 {
+ public ok2() {}
+ public void ok2() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateSwitchLabels.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateSwitchLabels.java
new file mode 100644
index 000000000000..d2f7c626be46
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/DuplicateSwitchLabels.java
@@ -0,0 +1,66 @@
+// duplicate labels
+import java.io.*;
+import java.net.*;
+
+public class a {
+
+ final int FI = 4;
+
+ void f(final int i) {
+ switch (i) {
+ default: break;
+ case 1: break;
+ default: break;
+ }
+
+ switch (i) {
+ case 1: break;
+ case 1: break;
+ }
+
+ switch (i) {
+ case FI/2 - 1: break;
+ case (1 + 35/16)%2: break;
+ case FI - 8: break;
+ }
+
+ final byte b = 127;
+
+ switch(i) {
+ case b:
+ System.out.println("b=" + b + ";");
+ case 127:
+ System.out.println("MySwitch.MySwitch");
+ }
+
+
+ // internalize strings
+ switch (0) {
+ case 0:
+ case "\410" == "!0" ? 1 : 0:
+ case ""==""+"" ? 3 : 0:
+ }
+
+ switch (0) {
+ case 0:
+ //case 1./0 == Double.POSITIVE_INFINITY ? 1 : 0:
+
+ //case 1./0 == Float.POSITIVE_INFINITY ? 2 : 0:
+
+ // commented out ref
+ // does not work when running under JRE
+ //case -1./0 == Double.NEGATIVE_INFINITY ? 3 : 0:
+ //case -1./0 == Float.NEGATIVE_INFINITY ? 4 : 0:
+ //case Double.POSITIVE_INFINITY == Float.POSITIVE_INFINITY ? 5 : 0:
+ //case Double.NEGATIVE_INFINITY == Float.NEGATIVE_INFINITY ? 6 : 0:
+ //case Double.NaN != Float.NaN ? 7 : 0:
+ //case Integer.MIN_VALUE == -2.147483648e9 ? 8 : 0:
+ //case Integer.MIN_VALUE == -2.14748365e9f ? 9 : 0:
+ //case Long.MIN_VALUE == -9.223372036854776e18 ? 10 : 0:
+ //case Long.MIN_VALUE == -9.223372e18f ? 11 : 0:
+
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java
new file mode 100644
index 000000000000..d77559a024ac
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/EnclosingInstance.java
@@ -0,0 +1,88 @@
+// no enclosing instance when inheriting inner class
+
+
+class A57 {
+ class X {
+ }
+ void f() {
+ class XL extends A57.X {
+ }
+
+ }
+ class XXL extends A57.X {
+ }
+}
+class B57 {
+ class X extends A57.X {
+ }
+}
+class C57 extends B57.X {
+}
+
+
+class inner_holder {
+ class inner {}
+}
+
+public class C1_57 extends inner_holder {
+ // inner instance available through inheritance
+ protected class c extends inner {
+ private class iii extends inner {}
+ }
+}
+
+/////////////////////////////////////
+class ParentA {
+ class InnerA {
+
+ }
+}
+
+class ParentB extends ParentA {
+ static class InnerB extends InnerA {
+
+ }
+ class InnerC extends InnerA {
+
+ }
+}
+////////////////////////
+class c {
+ static class s {
+ void f() {
+ Object o = this;
+ }
+ }
+ void f() {}
+}
+
+class cc {
+ static class sc extends c {
+ void f() {
+ super.f();
+ }
+ }
+}
+///////////////////////////
+class A
+{
+ class B
+ {
+ class C{}
+ }
+}
+class AB extends A.B {
+ AB(A a) {
+ a.super();
+ }
+ AB() {
+ this(new A());
+ }
+}
+class ABIllegal extends A.B {
+ ABIllegal(A a) {
+ }
+ ABIllegal() {
+ this(new A());
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java
new file mode 100644
index 000000000000..5158a74fb0e6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrown.java
@@ -0,0 +1,105 @@
+// Exception is never thrown in method
+
+import java.io.*;
+import java.sql.*;
+
+class a {
+ private void f() throws IOException {
+ }
+ public void usef() throws Exception {
+ f(); //avoid unused f()
+ }
+
+ private void f2() throws IOException {
+ try {
+ throw new IOException();
+ }
+ finally {
+ return;
+ }
+ }
+ public final void f3() throws IOException {
+ }
+ public static void f4() throws IOException {
+ }
+
+ public void usef2() throws Exception {
+ f2(); //avoid unused f()
+ }
+ public void usef3() throws Exception {
+ f3(); //avoid unused f()
+ }
+ public void usef4() throws Exception {
+ f4(); //avoid unused f()
+ }
+
+}
+
+final class Final {
+ {
+ new Object() {
+ void f() throws IOException {}
+ };
+ }
+
+ void f() throws IOException {}
+ public void f1() throws IOException {}
+ protected void f2() throws IOException {}
+}
+
+
+
+class a1 {
+ a1() throws java.io.IOException, SQLException{
+ }
+
+}
+
+class b1 extends a1 {
+ b1() throws IOException, SQLException {
+ }
+}
+
+////////////////////////////////
+public class FooThrow
+{
+ final Foo foo = new Foo(); // Can throw FooException
+ FooThrow() throws Foo {
+ }
+}
+class Foo extends Exception {
+ public Foo() throws Foo {
+ throw new Foo();
+ }
+}
+//////////////
+class H {
+ public H() throws FileNotFoundException {
+ }
+
+ {
+ if(true) {
+ throw new FileNotFoundException();
+ }
+ }
+}
+
+class PossibleIdeaBugs implements java.io.Serializable {
+
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws java.io.IOException, ClassNotFoundException {
+ }
+
+
+ private Object writeReplace() throws java.io.ObjectStreamException {
+ return this;
+ }
+
+ private Object readResolve() throws java.io.ObjectStreamException {
+ return null;
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrownInTry.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrownInTry.java
new file mode 100644
index 000000000000..38782c3bd933
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExceptionNeverThrownInTry.java
@@ -0,0 +1,13 @@
+import java.io.*;
+import java.sql.*;
+
+////////////
+class x {
+ void f() {
+ try {
+ int i = 0;
+ }
+ catch (IOException e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExtendsClause.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExtendsClause.java
new file mode 100644
index 000000000000..a436f1ee38af
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ExtendsClause.java
@@ -0,0 +1,4 @@
+class s {
+ int i;
+ class inn extends i {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java
new file mode 100644
index 000000000000..17bd29a20846
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/FinalFieldInit.java
@@ -0,0 +1,223 @@
+// final Fields initialization
+import java.io.*;
+import java.net.*;
+import java.awt.event.*;
+
+public class a {
+ /**
+ * javadoc should not be highlighted
+ */
+ final int javaDoced;
+
+ static final int sfi1;
+ static final int sfi2;
+ final int fi1;
+ final int fi2;
+
+ class inner {
+ final int fii;
+ }
+ final int fi3;
+ final int fi4;
+
+
+ static final int csfi1 = 0;
+ static final int csfi2 = csfi1 + 13 / 5;
+ static final int csfi3;
+ static {
+ if (csfi1 < 13) {
+ csfi3 = csfi2 + (csfi1 == 4 ? 5 : csfi2/13);
+ }
+ else {
+ csfi3 = 0;
+ sfi2 = 2;
+ }
+ }
+
+
+ final int cifi1 = 1;
+ final int cifi2 = ff();
+ final int cifi3;
+
+ int ff() {
+ int i = cifi1 + cifi2 + cifi3 + fi3 + fi4;
+ return i;
+ }
+
+ {
+ switch (cifi1) {
+ case 2: cifi3 = 2; break;
+ case 1: cifi3 = 20; break;
+ case 0: cifi3 = 21; break;
+ default: cifi3 = 22; break;
+ }
+ }
+
+ final int cifi4;
+ a() {
+ cifi4 = 4;
+ int i = fi3;
+ fi3 = 3;
+ a ainst = null;
+ fi4 = ainst.fi4;
+ }
+ a(int i) {
+ this.cifi4 = i;
+ fi2 = 3;
+ fi3 = 3;
+ a ainst = null;
+ fi4 = ainst.fi4;
+ }
+ a(String s) {
+ this(0);
+ int i = fi3;
+
+ }
+}
+
+class Test {
+ // access from within inner class OK
+ final boolean FB;
+ {
+ class s {
+ boolean b = FB;
+ }
+ FB = true;
+
+ }
+ private final String text;
+ public Test() {
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doSomething(text);////
+ }
+ };
+ text = "Hello world";
+ }
+
+ private void doSomething(String value) {
+ }
+}
+
+// multiple initalizers
+class c1 {
+ private final String x;
+ {
+ x = "Hello";
+ }
+
+ private final String y;
+ {
+ y = x;
+ }
+ void f() {
+ String s = x+y;
+ }
+}
+
+class c2 {
+ static {
+ }
+ private static final int limit;
+ static {
+ limit = 5;
+ }
+ final String s;
+ int k = s.length();
+ final String c;
+ int k2 = c.length();
+ {
+ s = "";
+ }
+
+ public c2() {
+ c = "";
+ }
+ // its ok
+ int k3 = c.length();
+
+ c2(int i) {
+ this();
+ }
+}
+
+class UninitializedFinal2 {
+ private final String s;
+
+ UninitializedFinal2(){
+ try {
+ }
+ finally {
+ }
+ }
+}
+class UninitedFinalFied {
+
+ private final String string;
+
+ public UninitedFinalFied() throws IOException {
+ init();
+ }
+
+ private void init() throws IOException {}
+}
+class AssertFinalFied {
+ private final String string;
+
+ public AssertFinalFied(boolean b) throws Exception {
+ assert b;
+ string = null;
+ }
+}
+
+class a20Exotic {
+ int n=k=0;
+ final int k;
+ final int k2;
+ int n2 = k==0 ? (k2=9) : (k2=0);
+}
+
+public class cX {
+ final int i;
+ cX() {
+ this(1);
+ int k = i;
+ }
+ cX(int d) {
+ i = d;
+ }
+}
+
+// http://www.intellij.net/tracker/idea/viewSCR?publicId=20097
+class Lemma {
+ public Lemma() {
+ name.hashCode();
+ }
+ private final String name;
+ { name = "Andy";
+ }
+}
+
+class correct {
+ void f() {
+ final Object o;
+ o = new Object();
+ new Object() {
+ { o.toString(); }
+ };
+ }
+}
+
+public class X {
+ final int i;
+ X() {
+ try {
+ i = 0;
+ }
+ finally {
+
+ }
+ }
+}
+
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11877.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11877.java
new file mode 100644
index 000000000000..7dfc0024180f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11877.java
@@ -0,0 +1,7 @@
+interface MyCloneable {
+
+ //protected method from java.lang.Object is not implicitly declared in interface with no base interfaces
+ int clone();
+
+ int toString();
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11919.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11919.java
new file mode 100644
index 000000000000..8181b03009c5
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV11919.java
@@ -0,0 +1,55 @@
+interface Bar {
+ void DoBar();
+}
+
+abstract class Foo {
+ public Foo(Bar b) {
+ }
+}
+
+class Inh extends Foo {
+ public Integer myField = new Integer(0);
+
+ public Inh() {
+ super(new Bar() {
+ public void DoBar() {
+ Inh.this.myField.toString();
+ }
+ });
+
+ class E extends Foo {
+ E() {
+ super(new Bar() {
+ public void DoBar() {
+ Inh.this.myField.toString();
+ }
+ });
+ }
+
+ public void DoBar() {
+ Inh.this.myField.toString();
+ }
+ }
+ Inh.this.myField.toString();
+ }
+
+ public Inh(Bar b) {
+ super(b);
+ }
+}
+
+//IDEADEV-14306
+class Base {
+ protected String field;
+
+ public Base(final String field, int l) {
+ this.field = field;
+ }
+}
+
+class Inhertior extends Base {
+ public Inhertior() {
+ super("", field.length());
+ }
+}
+//end of IDEADEV-14306
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV13249.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV13249.java
new file mode 100644
index 000000000000..3adc15d65c9d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV13249.java
@@ -0,0 +1,22 @@
+class TestSuper {
+ public static class A {
+ private String s = "A";
+
+ public void foo() {
+ System.out.println("A::foo");
+ }
+ }
+
+ public static class B extends A {
+
+ public void foo() {
+ super.foo();
+ System.out.println("B::foo " + super.s);
+ System.out.println("B::foo " + ((A) this).s);
+ }
+ }
+
+ public static void main(String[] args) {
+ new B().foo();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java
new file mode 100644
index 000000000000..99b6bc53b1b1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV25784.java
@@ -0,0 +1,13 @@
+public class X extends Y {}
+public class Y {
+
+ private static int x = 0;
+
+ public static int getX() {
+ return x;
+ }
+
+ public static void setX(int x) {
+ X.x = x;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV8822.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV8822.java
new file mode 100644
index 000000000000..23347d6f9719
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV8822.java
@@ -0,0 +1,8 @@
+class S extends S3 {
+ String XXX; //should correctly resolve to java.lang.String
+}
+
+class S3 {
+ private class String {
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV9201.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV9201.java
new file mode 100644
index 000000000000..322079a1b327
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IDEADEV9201.java
@@ -0,0 +1,6 @@
+class YouAreNotMyType {
+
+ String[][] oldLady() {
+ return new String[][]{new Integer[]{}};
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalModifiersCombination.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalModifiersCombination.java
new file mode 100644
index 000000000000..d682ba31f65d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalModifiersCombination.java
@@ -0,0 +1,74 @@
+// illegal modifier combinations
+
+abstract public class a {
+ //////////////////// fields ////////////////////////////////
+ public static
+ protected int f1 = 0;
+
+ public volatile
+ private int f2 = 0;
+
+ protected final
+ private int f3 = 0;
+
+ final
+ volatile private int f4 = 0;
+
+ public
+ public
+ int f5 = 0;
+
+ public static final int cf1 = 0;
+ static volatile private int cf2;
+ transient public static final int cf3 = 0;
+ protected volatile transient int cf4;
+ private static final int cf5 = 1;
+
+
+
+ ///////////////////// methods ///////////////////////////////////
+
+ abstract
+ native void m1();
+
+ static public
+ abstract void m2();
+
+ final
+ abstract void m3();
+
+ private static
+ public void m4() {}
+
+ protected final
+ private void m5() {}
+
+ public
+ public void m6() {};
+
+ public abstract void cm1();
+ protected static synchronized native void cm2();
+ public static final void cm3() {}
+
+
+ ///////////////////////// classes //////////////////////////////////
+ final static strictfp protected
+ abstract class c1 {}
+
+ private final
+ public class c2 {}
+
+ final
+ final class c3 {}
+
+ abstract protected static strictfp class cc1 {}
+ final private static class cc2 {}
+ class cc3 {}
+ static class cc4 {}
+
+ ///////////////////////// locals
+ void f() {
+ final
+ final int loc;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalType.java
new file mode 100644
index 000000000000..1fd25c89716b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalType.java
@@ -0,0 +1,8 @@
+
+ class Foo {
+ int k;
+ Class c=k.class;
+ void f() {
+ java.io javaio;
+ }
+ }
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalVoidType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalVoidType.java
new file mode 100644
index 000000000000..206be9026ba0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IllegalVoidType.java
@@ -0,0 +1,18 @@
+class s {
+ void f() {
+ // illegal type
+ void[] va;
+ void vv;
+ class loc {
+ void f(void i) {}
+ }
+ Object o = new void[1];
+
+ // this is the only valid void usage
+ Class voidClass = void.class;
+ }
+
+ {
+ Object o = f();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ImplicitConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ImplicitConstructor.java
new file mode 100644
index 000000000000..1402dec5d7c4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ImplicitConstructor.java
@@ -0,0 +1,9 @@
+class A_I extends B_I{
+ public A_I() {
+ super();
+ new B_I();
+ }
+}
+
+class B_I{
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IncompatibleTypes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IncompatibleTypes.java
new file mode 100644
index 000000000000..18f8b36cbb62
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/IncompatibleTypes.java
@@ -0,0 +1,80 @@
+class c {
+ void f() {
+ //---- switch --------------------------------------------------------
+ switch ("s")
+ {default:}
+ byte bt = 0;
+ switch (bt) {
+ case "S": break;
+ case 10L: break;
+ case true: break;
+ case 0xdfffffff: break;
+ case '\udede': break;
+ case 1280: break;
+ // assignable compatible to byte
+ case 0: break;
+ case 'c': break;
+ case -1: break;
+ case 127: break;
+ }
+ char ch = 'd';
+ switch (ch) {
+ case "S": break;
+ case 10L: break;
+ case true: break;
+ case 0xafffffff: break;
+ // assignable compatible to char
+ case 0: break;
+ case '\u4567': break;
+ case 0xffff: break;
+ case 255: break;
+ }
+ switch ('d') {default:}
+
+ /// --------- incompatible types inside array initializer ----------
+
+
+ int[] ia = new int[] {
+ "String"
+ , 3.4
+ };
+
+ String[] sa = { "s",
+ false
+ , 'S'
+ };
+
+ String[] vas = null;
+ Object o = new int[vas[0]];
+
+ int[] weird={{0}};
+ int[][] arrayInitializers = {{ }};
+ int[][][] arrayInitializers2 = {{ }, {{}} };
+ double[][] i2d = {{1}};
+ char[][] i2c = {{1}};
+ char foo = 0x0000; /* okay */
+ char[] bar = { 1,2,3 }; /* still okay */
+ char[][] baz = { { 1,2,3 } }; /* not okay in 4.5, okay in 4.0.x and for javac */
+
+
+ /// -------- conditional operator
+ int i8 = "ff" + true ? 1 : 2;
+ int i9 = 1==2 ? 1 : "ff" + true;
+ i9 = 1==2 ? 3 : null;
+ Object o9 = true ? 0 : new Object();
+
+
+
+ final char ccons='0';
+ short ssss=ccons;
+ byte bbbbbb=ccons;
+ // too big char to fit in short
+ final char bigchar='\uffff';
+ short sbig = bigchar;
+ }
+
+ void g(boolean f, byte b) {
+ byte c = '\n';
+ byte next = f ? b : '\n';
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InheritFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InheritFinal.java
new file mode 100644
index 000000000000..56e1265fe7da
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InheritFinal.java
@@ -0,0 +1,10 @@
+// inherit from final
+public class a extends ff {
+
+ void f() {
+ Object o = new ff() { void gg(){} };
+ }
+}
+
+final class ff {
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InitializerCompletion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InitializerCompletion.java
new file mode 100644
index 000000000000..2e270c0db875
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InitializerCompletion.java
@@ -0,0 +1,134 @@
+/// initalizers completion
+import java.io.*;
+import java.net.*;
+
+public class a {
+
+ {
+ throw new RuntimeException();
+ }
+
+ static {
+ try {
+ throw new RuntimeException();
+ }
+ finally {
+ throw new NullPointerException();
+ }
+ }
+
+
+}
+class a2 {
+ {
+ if (1==2) throw new IOException();
+ }
+
+ a2() {}
+}
+class a3 {
+ {
+ if (1==2) throw new SocketException();
+ }
+
+ a3() throws ConnectException {}
+}
+
+class b {
+
+ { if (1==2) throw new SocketException(); }
+
+ b() throws IOException {}
+}
+
+class a4 {
+ {
+ if (true) {
+ throw new Exception();
+ }
+ }
+ a4() throws Exception {
+ }
+}
+
+class a5 {
+ int i = f();
+
+ int f() throws ClassNotFoundException {
+ return 0;
+ }
+}
+class a6 {
+ int i = f();
+
+ int f() throws ClassNotFoundException {
+ return 0;
+ }
+
+ a6() throws ClassNotFoundException {
+ }
+}
+
+class a7 {
+{
+ try {
+ throw new RuntimeException();
+ } finally {
+ }
+ }
+}
+
+class MyRuntimeException extends RuntimeException {}
+
+class GUIBase {
+ GUIBase () throws MyRuntimeException {}
+}
+
+class GUI extends GUIBase {
+
+}
+
+
+class a8 {
+ {
+ assert true;
+ }
+ {
+ assert false;
+ }
+
+}
+
+class a9 {
+
+ private static interface AnInterface {}
+
+ public AnInterface getAnInterface() {
+ return new AnInterface() {
+ {
+ new java.io.FileInputStream("somefile");
+ }
+ };
+ }
+}
+
+////////////////////////////////
+class BadStatic {
+ static String f() throws ClassNotFoundException {
+ return null;
+ }
+ private static final String FOO = f();
+
+ public BadStatic() throws ClassNotFoundException {
+ }
+}
+class H {
+ public H() throws FileNotFoundException {
+ }
+
+ static {
+ if(true) {
+ throw new FileNotFoundException();
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InjectedAnnotator.xml b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InjectedAnnotator.xml
new file mode 100644
index 000000000000..8efde915514e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InjectedAnnotator.xml
@@ -0,0 +1,5 @@
+aaa="dddd">
+
+
+
+
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InstantiateAbstract.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InstantiateAbstract.java
new file mode 100644
index 000000000000..2a7456ec8de0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InstantiateAbstract.java
@@ -0,0 +1,37 @@
+// instantiate abstract
+public class a {
+ void f() {
+ new ii();
+
+ new c1();
+
+ new c1() {
+ public void f2() {}
+ };
+
+ new c1() {
+ public void f1() {}
+ };
+
+ new c1() {
+ public void f1(int i) {}
+ public abstract void f2();
+ };
+
+
+ new c1() {
+ public void f1(int i) {}
+ };
+ new ii() { public void f1(){} public void f2(){} };
+
+ }
+}
+abstract class c1 {
+ abstract public void f1(int i);
+}
+
+interface ii {
+ abstract void f1();
+ void f2();
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Interface.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Interface.java
new file mode 100644
index 000000000000..1dc6b8c535c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Interface.java
@@ -0,0 +1,20 @@
+interface i implements Runnable {}
+
+interface ii {}
+class cs extends ii {}
+interface is extends ii {}
+
+class cs2 implements cs {}
+interface is3 extends cs {}
+
+abstract class Exercis {
+ public static void main() {
+ Object o = java.lang.this;
+
+ new Runnable() {
+ public void run() {
+ Runnable.this.run(); ///
+ }
+ };
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java
new file mode 100644
index 000000000000..e676de4441ef
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/InvalidExpressions.java
@@ -0,0 +1,104 @@
+// invalid expressions
+public class a12 {
+ static int i;
+
+ int f(int i) {
+ 1;
+ 1==2;
+ 1==2 ? 1 : 3;
+ f(1) == 3;
+ 1,2;
+ ~1;
+ !(1==2);
+ new int[0];
+ new a12[10];
+ new a12[]{};
+ new int[]{1};
+ new String[]{new String()};
+ if (i==1)
+ String s00 = "";
+ for (;;)
+ String s01 = "";
+
+
+ for (1==2,i=3; i<3; !(1==2));
+
+ label2:
+ int ksdfgdf;
+
+
+ int i1=3, g=5;
+ g++;
+ ++g;
+ for (int k=1,l=3; k<3; k++,l--) {;};
+ class s {}
+ new s() { void f(){}};
+ return 3;
+ }
+
+
+
+ //////////////////////////
+ void f() {
+ a12 a[] = new a12[4];
+ int[] ai = null;
+
+ 5 = 5;
+ 5++;
+ ++5;
+ 5 += 5;
+
+ foo123Unresolved(String);
+ foo123Unresolved(xxxx);
+
+ // incomplete code should not cause 'expr expected'
+ Object
+
+
+ 4[1] = 5;
+ a["d"] = null;
+
+ a[0][1] = 5;
+ i[0] = 5;
+ i = ai[a[1]];
+
+ final a12[] a12a = new a12[{null}];
+ int[] iarr = new int[{0}];
+
+
+ new String["d"];
+ new String[1.1]
+ [this];
+
+ a[0] = null;
+ (a)[(1)].i = 3;
+ (( i) ) = (5);
+ a12.i = 0;
+ arr()[0] = 1;
+ new int[] { 1,3} [0] = 2;
+ Object[] var = null;
+ i = var.length;
+
+ // array initializers
+ var = { null, null };
+ Object var1 = { null, null };
+ int[] var2 = { 1,2 };
+ var2 = new int[] { 2, 4};
+ int[][] ii2 = { { 1,2}, {4} };
+
+ }
+ void[] fv() {
+ if (1==2) return new void[0];
+ return null;
+ }
+
+ int[] arr() { return new int[0]; }
+
+ public foo() {
+ }
+
+ // do not warn about illegal type in incomplete declarations (http://www.intellij.net/tracker/idea/viewSCR?publicId=9586)
+ void foo
+}
+
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Javadoc.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Javadoc.java
new file mode 100644
index 000000000000..4a73ec289aa0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Javadoc.java
@@ -0,0 +1,39 @@
+class a {
+ /**period.
+ * @return x
+ */
+ int f() {
+ return 0;
+ }
+ /**period.
+ * @return x wtf ?
+ */
+ int f2() {
+ return 0;
+ }
+
+ /**period.
+ * @return
+ * true if someone wants
+ */
+ int f3() {
+ return 0;
+ }
+
+
+ /**period.
+ * @param i description goes here
+ * @return
+ */
+ int f(int i) {
+ return i;
+ }
+
+
+ /**
+ * @see localVar
+ */
+ static String KEY_FOR_VAR="index.localVar";
+ String localVar;
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/LocalVariableInitialization.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/LocalVariableInitialization.java
new file mode 100644
index 000000000000..3c7be47387fe
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/LocalVariableInitialization.java
@@ -0,0 +1,418 @@
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+public class a {
+ static final a ai;
+ int ii;
+
+ static {
+ ai.ii = 4;
+ ai = null;
+ }
+
+ void f1(int i) {
+ int j;
+ i = j;
+ }
+ void f2(int i) {
+ int j;
+ if (i ==2) j = 4;
+ i = j;
+ }
+ void f3(int i) {
+ int j;
+ if (i==3 && (j=i) != 9) {
+ i = j+2;
+ }
+ else {
+ i -= -1 - j;
+ }
+ }
+ void f4(int i) {
+
+ final int dd;
+
+ Runnable r = new Runnable() {
+ public void run() {
+ int j = dd;
+ }
+ };
+
+ if (i == 3) dd = 5;
+ else dd = 6;
+ }
+ void f5(int i) {
+ final int k;
+ class inner {
+ void f() {
+ int j = k;
+ }
+ }
+
+ }
+ void f6(int a){
+ Object[] var;
+ if (a > 0){
+ }
+ else{
+ var = new Object[1];
+ }
+ System.out.println(var);
+ }
+
+
+ void f7() {
+ int k;
+ try {
+ k=0;
+ } finally {
+ if (k==0) {
+ }
+ }
+ }
+
+ void f8(int n)
+ {
+ int k;
+ while (n < 4) {
+ k = n;
+ break;
+ }
+ // k is not "definitely assigned" before this
+ System.out.println(k);
+ }
+
+ void f9() {
+ final int k;
+ k+=1;
+ }
+ void f10() {
+ final int k;
+ k++;
+ int i = i + 1;
+ int j = (j=2) == 1 || j==0 ? 1 : j;
+ }
+
+ void f11() {
+ int x = 0;
+ switch (x) {
+ case 0:
+ int y = 1;
+ System.out.println(y);
+ break;
+ case 1:
+ int z = y;
+ System.out.println(z);
+ break;
+ }
+ }
+ void f12() {
+ switch (0) {
+ case 0:
+ int k=0;
+ case 1:
+ System.out.println(k);
+ }
+ }
+
+ public class AInner {
+ class AI2 {}
+ private AI2 myTitleRenderer = new AI2() {
+ private String myLabel = "";
+
+ public String getTreeCellRendererComponent(String value) {
+ if (value instanceof String) {
+ int i = myLabel.length();
+ }
+ return null;
+ }
+ };
+ }
+
+ void f13() {
+ int i ;
+ try {
+ i = 0;
+ if (i==0) throw new IOException();
+ }
+ catch (IOException e) {
+ if (i==0) return;
+ }
+ }
+
+ abstract class X {
+ class XException extends Exception{}
+ class YException extends Exception{}
+ class ZException extends Exception{}
+ public void test() throws XException {
+ final Object obj;
+ try {
+ obj = test1();
+ }
+ catch (YException fnf) {
+ }
+ finally {
+ try {
+ test2();
+ }
+ catch (ZException eof) {
+ }
+ }
+ obj.hashCode(); //can stay uninitialized
+ }
+
+ public abstract Object test1() throws YException, XException;
+
+ public abstract void test2() throws XException, ZException;
+ }
+
+ public static int test(List aList) {
+ List list2;
+ int counter = 0;
+ for (int i=0; ilist2.add(aList.get(i));
+ }
+ return counter;
+ }
+
+ void forEachParam(java.io.File x) {
+ for (java.io.File f: f.listFiles()) {
+ forEachParam(f);
+ }
+ }
+
+ // all code below is correct
+ int cf1(int i) {
+ return i;
+ }
+
+ void cf2(int i) {
+ int j;
+ if (i == 0 && (j=i) != 2) {
+ i = j;
+ }
+ if (i == 0 || (j=i) != 2 || j>3) {
+ i = 2;
+ }
+ }
+
+ boolean cf3(int i) {
+ final int j;
+ if (i<3 || i>33) j = i;
+ else j = 4;
+ i = j;
+
+ return i==3 && i==5;
+ }
+ void cf33(int i) {
+ final int j2;
+ while (true) {
+ j2 = 5;
+ break;
+ }
+ i = j2;
+ }
+
+ void cf4() {
+ final int i1;
+ int i2;
+ final Object o1;
+ }
+ void cf5() {
+ final int dialog = 3;
+
+ final int dd;
+ if (dialog == 3) dd = 5;
+ else dd = 6;
+
+ Runnable r = new Runnable() {
+ public void run() {
+ int i = dialog;
+ int j = dd;
+ }
+ };
+
+ }
+ void cf6() {
+ class inner extends a {
+ void fi() {
+ int i = ii;
+ }
+ }
+ a ainst = new a() {
+ void fi() {
+ int i = ii;
+ }
+ };
+ }
+ a() {
+ int i = ai.ii;
+ }
+ void cf7() {
+ for(int i = 0; i < 3; i++){
+ Object element;
+ if (i==0){
+ element = null;
+ }
+ else if (i==3){
+ element = null;
+ }
+ else{
+ continue;
+ }
+ Object newe = element;
+ }
+ }
+ void cf8(int n)
+ {
+ int i;
+ while (true) {
+ if (false) {
+ i = 0;
+ break;
+ }
+ }
+ i++;
+
+ }
+ final boolean FB = true;
+
+ void cf9() {
+ int k;
+ if (FB) {
+ k = 4;
+ }
+ int j = k;
+ }
+
+
+ void cf10() {
+ for (String line; (line = "") != null; ) {
+ line.indexOf(" ");
+ }
+ }
+
+ void cf11(boolean d) {
+ boolean b;
+ boolean c = true;
+ if (c && (false && true)) {
+ c = b;
+ }
+ }
+ void cf12() {
+ boolean booleanVar = true;
+ boolean stringVar;
+ if (!(booleanVar && (stringVar = true))) {
+ stringVar = false;
+ }
+ if (stringVar) {
+
+ }
+ }
+
+ void cfxx(boolean a, boolean b) {
+ int n;
+ if ((a || b) && (n = 0) >= 2) {
+ n++; //
+ }
+ }
+ void cfxx1(boolean a, int b) {
+ final int i;
+ if ((true || false) && (i = b) != 0) {
+ System.out.println(i); // i gets highlighted }
+ }
+ }
+ void cfx3() {
+ boolean b;
+ boolean c;// = true;
+ if (c && false) {
+ c = b;
+ }
+ }
+ void cfx4()
+ {
+ final int k;
+ if (false) {
+ k = 0;
+ k = 1;
+ System.out.println(k);
+ }
+ }
+}
+
+
+class Main {
+ void f() {
+ final int x;
+ x = 0;
+ class C {
+ void m () {
+ int y = x;
+ }
+ }
+ }
+}
+
+
+// continue in finally
+class QuartzSchedulerThread {
+ public void run() throws IOException {
+ while (true) {
+ try {
+ } finally {
+ try {
+ run();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ continue;
+ }
+ }
+ }
+
+}
+class ExceptionProblems {
+
+ private boolean bad() {
+ final boolean succeeded;
+ try {
+ new FileInputStream("test");
+ succeeded = true;
+ } catch (IOException e) {
+ succeeded = false; // should warn here
+ }
+ return succeeded;
+ }
+}
+class ImGood {
+ int foo() { //IDEADEV-7446
+ int foo;
+ if (true) {
+ foo = 42;
+ }
+ return foo;
+ }
+ }
+
+class SwitchTest
+{
+ public static String method()
+ {
+ int a = 0;
+ switch (a)
+ {
+ case 0:
+ return null;
+ case 4:
+ String description;
+ return description;
+ default:
+ return "";
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Loop.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Loop.java
new file mode 100644
index 000000000000..600bae3ca7db
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Loop.java
@@ -0,0 +1,67 @@
+// continue outside of.../loop label
+public class a {
+
+ void f() {
+ continue;
+ while (true) {
+ continue;
+ }
+ do { continue; } while (true);
+ switch (1) {
+ case 1: continue;
+ }
+ for (;;) {
+ continue;
+ }
+
+ for (;;) {
+ new ff() {
+ void f() {
+ continue;
+ }
+ };
+ continue;
+ }
+
+
+ while (true) {
+ class s {
+ {
+ continue;
+ }
+ }
+ continue;
+ }
+
+ do {
+ class s {
+ {
+ continue;
+ }
+ }
+ continue;
+ } while (true);
+
+
+
+ a:
+ if (2==4) {
+ for (;;) {
+ continue a;
+ }
+ }
+
+ a:
+ b:
+ for (;;) {
+ continue a;
+ }
+
+
+
+ }
+}
+
+class ff {
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java
new file mode 100644
index 000000000000..c6fc37d77092
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCalls.java
@@ -0,0 +1,104 @@
+// illegal method calls
+
+class A {
+ private class B {
+ Object o = super;
+ }
+ private B b = null;
+ A(A a)
+ {
+ new A(a).new B();
+ B b = new A(a).b;
+ AA aa = (AA) a;
+ AA.SAA saa = aa.new SAA();
+ AA.SAA saa1 = new AA.SAA();
+ }
+}
+
+class AA extends A {
+ private AA aa;
+ AA(A a) {
+ super(a);
+ }
+ class SAA {}
+
+ void f() {
+ new AA.SAA();
+ new SAA();
+ AA.this.aa.new SAA();
+
+ class MyAA extends AA {
+ public MyAA(A a) {
+ super(a);
+ }
+ }
+ }
+}
+
+class AX {
+ class B {
+ }
+}
+class CX {
+ {
+ new AX.B();
+ }
+}
+
+
+
+class c {
+ c() {
+
+ }
+ class inner {
+ class ininner {}
+ }
+
+
+ static void f() {
+ new inner();
+ }
+
+ static {
+ new inner();
+ }
+}
+
+
+class A1 {
+ void f() {}
+}
+class B1 {
+ void f() {
+ A1.f();
+ }
+}
+
+class AAAA implements java.io.Serializable
+{
+ public AAAA ()
+ {
+ super(); // here
+ }
+}
+
+class DCC {
+ public DCC(int i) {
+ }
+
+ public DCC(int i, int z) {
+ DCC(i);
+ }
+ void f() {
+ DCC(1);
+ new DCC(1);
+ }
+}
+
+class ThisExpression {
+ static String foo() {
+ System.out.println(this);
+ return this.toString();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCannotBeApplied.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCannotBeApplied.java
new file mode 100644
index 000000000000..6191dc926344
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MethodCannotBeApplied.java
@@ -0,0 +1,7 @@
+class A {{
+ String.valueOf(chars, 0, 10); // all arguments are highlighted when only chars has a problemij
+ new String(chars, 0, 10); // highlighting is good here.
+
+ String.valueOf(0, 0, 10);
+ new String(0, 0, 10);
+}}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ModifierAllowed.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ModifierAllowed.java
new file mode 100644
index 000000000000..99b79745b48e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ModifierAllowed.java
@@ -0,0 +1,68 @@
+// not allowed modifiers
+private
+static
+volatile
+class a {
+
+ static
+ private
+ public
+ abstract {
+ int i = 4;
+ }
+ synchronized Object x;
+
+
+ private class c1 {
+ private void ff() {}
+ }
+ static strictfp class c2 {}
+
+ private static interface ii {
+ private int f1 = 2;
+ protected int f2 = 2;
+ public int f3 = 3;
+
+
+ private int f1();
+ protected int f2();
+ public int f3();
+ void f4();
+
+ }
+
+ void f1(final String i) {
+ final int ii = 3;
+ private int i2;
+ static int i3;
+
+ try {
+ throw new Exception();
+ } catch (final static Exception e) {
+ }
+ }
+
+}
+
+interface ff {
+ static class cc {}
+}
+
+abstract class c {
+ abstract c();
+ static c(int i) {}
+ native c(boolean b);
+ final c(char c) {}
+ strictfp c(String s) {}
+ synchronized c(Object o) {}
+}
+
+interface i3 {
+ strictfp int f1;
+ transient int f2;
+ synchronized int f3;
+
+ strictfp int m1() { return 0; }
+ transient int m2() { return 0; }
+ synchronized int m3() { return 0; }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeBoolean.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeBoolean.java
new file mode 100644
index 000000000000..ff5afd5677ad
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeBoolean.java
@@ -0,0 +1,20 @@
+class c {
+ void f() {
+ Object o = null;
+ if (o) {
+ return;
+ }
+
+ String str1 = "";
+ String str2 = "";
+ do {}
+ while (str1 = str2);
+
+ int i8 = "ff" + true ? 1 : 2;
+
+ assert 0;
+ assert 'a';
+ assert "";
+ assert f();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeFinal.java
new file mode 100644
index 000000000000..f2a914b6ff60
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeFinal.java
@@ -0,0 +1,12 @@
+class m {
+ int i;
+ void f() {
+ int r = 0;
+ new Runnable() {
+ public void run() {
+ int k = r;
+ int ii = i;
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeThrowable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeThrowable.java
new file mode 100644
index 000000000000..bd4e59b434db
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/MustBeThrowable.java
@@ -0,0 +1,46 @@
+class c {
+ void f1() {
+ try {
+ } catch (Error[] e) {
+ }
+ try {
+ } catch (Error e[]) {
+ }
+ try {
+ } catch (Error[] []e[] []) {
+ }
+ catch(int e) {
+ }
+
+ }
+
+}
+
+class MyException // does not extend Throwable
+{}
+
+class a60
+{
+ public void test() throws MyException
+ {
+ throw new MyException();
+ }
+ public void test(int i) {
+ switch (i) {
+ case 1: throw false;
+ case 2: throw 1;
+ case 3: throw 1.0;
+ case 4: throw 'a';
+ case 5: throw 1L;
+ case 6: throw 1.0f;
+ }
+ }
+}
+
+ class Contest {
+ short midget;
+
+ void strongMan() throws midget {
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NamesHighlighting.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NamesHighlighting.java
new file mode 100644
index 000000000000..1cab6140cb63
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NamesHighlighting.java
@@ -0,0 +1,59 @@
+import java.io.*; // highlight on demand import as class name
+
+class a {
+ void method() {
+ method();
+
+ new Exception();
+ new java.lang.Exception();
+ }
+ a() {
+ new a();
+ }
+
+ /**
+ * @see itf#method(double)
+ */
+ static void f() {
+ Integer.parseInt("");
+ java.lang.Integer.parseInt("");
+ f();
+ }
+
+ interface itf{
+ int CONST = 0;
+ /** .
+ * @param d Important param
+ */
+ void method(double d);
+ }
+ void ff(Runnabler) {
+ ff(
+ new java.lang.Runnable()
+ {
+ public void run() {}
+ int instance = 0;
+ }
+ );
+
+ int i = java.lang.Integer.MIN_VALUE;
+ int j = itf.CONST;
+ }
+}
+
+class NoCtrClass {
+ {
+ // default constructor call looks like class
+ new NoCtrClass();
+ }
+ void ff(int param) {
+ int i = 1;
+ i ++;
+
+ param = 0;
+ }
+}
+
+class Generic<TT extends Runnable> {
+ TTfield;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java
new file mode 100644
index 000000000000..86ac91d25e03
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericLiterals.java
@@ -0,0 +1,64 @@
+/// assignment compatible types
+import java.io.*;
+import java.net.*;
+public class a {
+ final int FI = 2;
+ final int FIBIG = 200000000;
+
+
+ void f() {
+ int i1=-2147483649;
+ int i2=2147483648;
+ int i3 = -2147483648;
+ int i4 = -0x7fffffff;
+ int i5 = -017777777777;
+ int i6 = 0x;
+ int i7 = 0xdeadbeef;
+ int i8 = 0xffffffff;
+ int i9=0xffffffff9;
+ int i10= 0x80000000;
+ int i11=0000000000000+0x000000000;
+ int i12=0x00000000000000000000000;
+ int i13= 040000000000;
+ int i14= 020000000000;
+ int i15 = 0xf044332211;
+ int octale = 017777777777; // negative
+
+
+
+ long l1=-9223372036854775809L;
+ long l2=9223372036854775808L;
+ long l3=-9223372036854775808L;
+ long l4=-2147483649;
+ long l5=2147483648;
+ long l6 = 0xL;
+ long l7= 0xdeadbeefffffffffL;
+ long l8= 0xffffffffffffffffL;
+ long l9=0xffffffffffffffff9L;
+ long l10=0x8000000000000000L;
+ long octalValue = 01777777777777777777600L;
+ long octalValua = 01777777777777777777777L;
+
+ float f1= 1e-46f;
+ float f2=1e39f;
+ float f3=0E1F;
+
+ double dd1=1e-324;
+ double dd2=1e309;
+ double dd3=0E1;
+
+ double d1=1.E;
+ double d2=1.e;
+ double d3=1.E+;
+ double d4=1.E-;
+ double d5=.1eD;
+ double d6=.1e+D;
+ double d7=1e+D;
+ double d8=1e-D;
+ double d9=1e-d;
+ double d10=1e-F;
+ double d11=1e-f;
+
+
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericOverflow.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericOverflow.java
new file mode 100644
index 000000000000..742d5fe9d2cc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/NumericOverflow.java
@@ -0,0 +1,88 @@
+// overflows in const expressions
+
+
+class c {
+ // @*#$& ! references do not work in JRE
+ static final long LONG_MIN_VALUE = 0x8000000000000000L;
+ static final long LONG_MAX_VALUE = 0x7fffffffffffffffL;
+ static final int INTEGER_MIN_VALUE = 0x80000000;
+ static final int INTEGER_MAX_VALUE = 0x7fffffff;
+ static final float FLOAT_MIN_VALUE = 1.4e-45f;
+ static final float FLOAT_MAX_VALUE = 3.4028235e+38f;
+ static final double DOUBLE_MIN_VALUE = 4.9e-324;
+ static final double DOUBLE_MAX_VALUE = 1.7976931348623157e+308;
+
+ void f() {
+ float f1 = 1.0f / 0.0f;
+ f1 = FLOAT_MAX_VALUE + FLOAT_MAX_VALUE;
+ f1 = FLOAT_MAX_VALUE * 2;
+ f1 = 2 / FLOAT_MIN_VALUE;
+ f1 = FLOAT_MIN_VALUE + 1;
+ f1 = - FLOAT_MIN_VALUE;
+ f1 = -FLOAT_MAX_VALUE;
+ System.out.println(f1);
+
+ double d1 = DOUBLE_MAX_VALUE - -DOUBLE_MAX_VALUE;
+ d1 = DOUBLE_MAX_VALUE + 1;
+ d1 = 2 * DOUBLE_MAX_VALUE;
+ d1 = 2 / DOUBLE_MIN_VALUE;
+ d1 = 2 / 0.0d;
+ d1 = 2 / 0.0;
+ System.out.println(d1);
+
+
+ int i1 = INTEGER_MAX_VALUE + 1;
+ i1 = INTEGER_MAX_VALUE - 1 + 2;
+ i1 = INTEGER_MAX_VALUE - INTEGER_MIN_VALUE;
+ i1 = -INTEGER_MIN_VALUE;
+ i1 = INTEGER_MIN_VALUE - 1;
+ i1 = INTEGER_MIN_VALUE - INTEGER_MAX_VALUE;
+ i1 = INTEGER_MIN_VALUE + INTEGER_MAX_VALUE;
+ i1 = - INTEGER_MAX_VALUE;
+ i1 = - -INTEGER_MAX_VALUE;
+ i1 = INTEGER_MIN_VALUE * -1;
+ i1 = INTEGER_MIN_VALUE * 2;
+ i1 = INTEGER_MAX_VALUE * -2;
+ i1 = INTEGER_MAX_VALUE * -1;
+ i1 = 2 / 0;
+ i1 = INTEGER_MIN_VALUE / -1;
+ System.out.println(i1);
+
+ long l1 = LONG_MAX_VALUE + 1;
+ l1 = LONG_MAX_VALUE - 1 + 2;
+ l1 = LONG_MAX_VALUE - LONG_MIN_VALUE;
+ l1 = -LONG_MIN_VALUE;
+ l1 = LONG_MIN_VALUE - 1;
+ l1 = LONG_MIN_VALUE - LONG_MAX_VALUE;
+ l1 = LONG_MIN_VALUE + LONG_MAX_VALUE;
+ l1 = - LONG_MAX_VALUE;
+ l1 = - -LONG_MAX_VALUE;
+ l1 = -INTEGER_MIN_VALUE;
+ l1 = -1L + INTEGER_MIN_VALUE;
+ l1 = LONG_MIN_VALUE * INTEGER_MIN_VALUE;
+ l1 = LONG_MIN_VALUE * -1;
+ l1 = LONG_MIN_VALUE * 2;
+ l1 = LONG_MAX_VALUE * -2;
+ l1 = INTEGER_MIN_VALUE * -1L;
+ l1 = 2 / 0L;
+ l1 = 2 % 0L;
+ l1 = LONG_MIN_VALUE / -1;
+
+ l1 = 30 * 24 * 60 * 60 * 1000;
+ l1 = 30000000 * 243232323
+ * (LONG_MAX_VALUE +3) / 5;
+ System.out.println(l1);
+
+
+
+ }
+
+ private static final long MILLIS_PER_DAY = 24 * 3600 * 1000;
+ private static final long _7DAYS = 7 * MILLIS_PER_DAY;
+ private static final long _30DAYS = 30 * MILLIS_PER_DAY;
+ private static final long _1000DAYS = 1000 * MILLIS_PER_DAY;
+ {
+ System.out.println(_1000DAYS + _30DAYS + _7DAYS);
+ }
+ int iii = 2 % 0;
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OperatorApplicability.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OperatorApplicability.java
new file mode 100644
index 000000000000..8b577ba54a7d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OperatorApplicability.java
@@ -0,0 +1,70 @@
+// operators applicability
+public class a {
+
+ int f(int ik) {
+ if (1 < null) {}
+ if (null == 'c') {}
+ Object o = null;
+ if (1.2 >= o) {}
+ if (1L != "null") {}
+ if ((1==2) == 3) {}
+
+ int i = (1 + null);
+ i = o/o;
+ i = null - 1.2;
+ i = true % 4;
+
+ i = i << o;
+ i = (i==2) >> null;
+ i = i >>> 2.2;
+
+ i = i & o;
+ i = true | 2.1;
+ i = 2 && 3;
+ i = 3.8 || 2L;
+ i = null || o;
+
+ i |= null;
+ double d = 0;
+ d &= i;
+ o /= 3;
+
+
+ String sss2 = "" + fvoid();
+ int sss1 = fvoid() + 2;
+
+ int ia[] = null;
+ boolean b = 1==3 || 3 < '4' && (1>3.5) == (o == null) || false || (o == "d");
+ b = (1 != 'f') == (3.4 >= 'x') && o!=null & (b | (3<4));
+ i = i & 2 | i>>i ^ 15>>>4 & ~ia[i-- + (int)d] - (int)d;
+
+ b |= (i &= 7) == 5 | (null == null);
+ d *= (i -= 3) / 13.4;
+ ia[0]++;
+ ia[~i | (i+=(!b?2:i))] -= i + 3.3;
+
+ // Object += String
+ o += o + "string";
+
+ return 0;
+ }
+
+ void fvoid() {}
+
+}
+
+class Test
+{
+ public void test(TestB a)
+ {
+ if(a == this)
+ {
+ System.out.println("a is equals to this");
+ }
+ }
+
+ public static interface TestB
+ {
+ public void bla();
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverriddenMethodIsFinal.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverriddenMethodIsFinal.java
new file mode 100644
index 000000000000..b1c3dd44e3a6
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverriddenMethodIsFinal.java
@@ -0,0 +1,14 @@
+
+interface ConflictWithObject {
+ public void notify();
+}
+
+//--override final-------------------------------------------------------------------------
+class base {
+ final void f() {}
+}
+class derived extends base {
+
+ void f() {}
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverrideConflicts.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverrideConflicts.java
new file mode 100644
index 000000000000..3aaa540d2a0c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/OverrideConflicts.java
@@ -0,0 +1,88 @@
+// throws conflicts on overriding/ override final
+import java.io.*;
+import java.net.*;
+public class a extends c3 {
+ public void f() throws Exception {
+ }
+}
+
+interface i {
+ void f() throws java.net.SocketException;
+}
+class c2 implements i {
+ public void f() throws java.io.IOException {}
+}
+class c2i implements i {
+ public void f() throws Exception {}
+}
+
+class c3 implements i {
+ public void f() throws java.net.ConnectException {}
+}
+
+class c4 extends c3 {
+ public void f() throws java.net.ConnectException {}
+}
+
+interface MethodsFromObject {
+ Object clone();
+}
+interface im extends MethodsFromObject {
+}
+class cm implements MethodsFromObject {
+}
+
+// sibling inheritance
+class c5 { public void f() throws Exception {} }
+interface i5 { void f(); }
+class c6 extends c5 implements i5 {
+}
+
+// overriding method does not throw exception, its OK
+class c {
+ protected Object clone() {
+ return null;
+ }
+}
+interface i6 {
+
+}
+class b extends c implements i6 {
+
+}
+
+
+//-------------- methods with same signature
+interface AContract
+{
+ void invoke () throws Exception;
+}
+
+class A implements AContract
+{
+ public void invoke () throws Exception { }
+}
+
+interface BContract
+{
+ void invoke ();
+}
+
+class B extends A implements BContract
+{
+ public void invoke () { }
+}
+
+class C extends B
+{
+}
+
+
+//////////////////////
+class Bug extends AbstrColl implements java.io.Serializable {
+}
+interface Coll {
+ boolean equals(Object f);
+}
+class AbstrColl implements Coll {}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedNew.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedNew.java
new file mode 100644
index 000000000000..28ed2c23d5e9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedNew.java
@@ -0,0 +1,19 @@
+// Qualified new of static class
+
+class A {
+ b b;
+ A() {
+ b.new c();
+ b.new inner();
+ }
+ class inner {}
+
+ void f() {
+ char[] c = b.new char[0];
+ }
+}
+
+class b extends A {
+ static class c {}
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedSuper.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedSuper.java
new file mode 100644
index 000000000000..24c34449db3e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifiedSuper.java
@@ -0,0 +1,48 @@
+class Outer {
+ class Inner1 extends Outer {
+ Inner1() {}
+ Inner1(Outer o) {}
+ }
+
+ class Inner2 extends Inner1 {
+ public Inner2(Object o) {
+ o.super();
+ }
+ public Inner2(int o) {
+ Outer.this.super();
+ }
+ public Inner2(Outer o) {
+ o.super(Outer.this);
+ }
+ public Inner2(Outer o, int par) {
+ o.super(this);
+ }
+ public Inner2(Outer o, Object par) {
+ this.super(o);
+ }
+ }
+
+ class BadInner extends Inner1 {
+ BadInner() {}
+ }
+ class BadInner2 extends Inner1 {
+ }
+
+ class s {
+ void f(Object o) {
+ new s();
+ Outer.this.new s();
+ }
+ }
+}
+
+class Outer2 {
+ class Inner {}
+}
+class Ext extends Outer2 {
+ class ExtInner extends Inner {
+ ExtInner() {
+ super();
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifierBeforeClassName.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifierBeforeClassName.java
new file mode 100644
index 000000000000..1edd34fe5247
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/QualifierBeforeClassName.java
@@ -0,0 +1,14 @@
+class E {
+ class Outer {
+ class S {
+ public static final int SS = 0;
+ }
+ }
+
+ Outer f() {
+ int s = f().S.SS;
+ int s1 = this.Outer.S.SS;
+ int s2 = Outer.S.SS;
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java
new file mode 100644
index 000000000000..149f62c06438
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java
@@ -0,0 +1,154 @@
+// reference before ctr called
+import java.io.*;
+import java.net.*;
+
+class a {
+ a(int i) {}
+ a(a a) {}
+ int f() { return 0; }
+ int fi;
+}
+
+class b extends a {
+ int bi;
+ b(int h) {
+ super(bi);
+ }
+ b() {
+ this(bi);
+ }
+
+ b(String s) {
+ super(db(1) );
+ }
+
+ b(int i, int j) {
+ super(f());
+ }
+ b(int i, int j, int k) {
+ super(super.f());
+ }
+
+ b(String s, int i) {
+ super(s.length());
+ }
+
+ b(int s, int i, char j) {
+ super(super.fi );
+ }
+
+ b(double d) {
+ super(new inner() );
+ }
+ class inner extends a {inner(){super(1);}}
+
+ int db(int j) {
+ return 0;
+ }
+}
+
+
+class enc {
+ int ienc;
+ class bb extends a {
+ int ibb;
+ bb() { super(ienc); }
+ bb(int i) {
+ super(i);
+ }
+
+ bb(int i, int j) {
+ super(enc.bb.this.ibb );
+ }
+
+ bb(int i, String s) {
+ super(enc.this.ienc);
+ }
+
+ bb(int i, char j) {
+ super(this );
+ }
+
+
+ }
+
+ enc() {
+ this(new bb());
+ }
+ enc(bb b) {}
+}
+
+// static are OK
+class c2 extends a {
+ static final int fi = 4;
+ c2() {
+ super(fi);
+ }
+ c2(int i) {
+ super(sf());
+ }
+ static int sf() { return 0; }
+
+ c2(int i, int j) {
+ super(new sc().i);
+ }
+ static class sc {
+ int i;
+ }
+
+}
+
+interface Callback {
+ void call();
+}
+
+class Base {
+ Callback callback;
+
+ public Base(final Callback callback) {
+ this.callback = callback;
+ }
+}
+
+class YellinBug extends Base {
+
+ public YellinBug() {
+ super(new Callback() {
+
+ public void call() {
+ YellinBug.this.f();
+ }
+ });
+ }
+
+ private void f() {}
+
+ {
+ new Callback() {
+
+ public void call() {
+ YellinBug.this.f();
+ }
+ };
+ }
+}
+
+class Outer {
+ class Inner extends Outer{}
+ class UseIt extends Inner{
+ Outer o;
+ UseIt() {
+ o.super();
+ }
+
+ Outer geto() {
+ return null;
+ }
+ UseIt(int x) {
+ geto().super();
+ }
+ UseIt(Outer x) {
+ this.super();
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Return.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Return.java
new file mode 100644
index 000000000000..f75c60247282
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Return.java
@@ -0,0 +1,20 @@
+class s {
+ void f() {
+ return 0;
+ }
+ void f2() {
+ return;
+ }
+
+ int f3() {
+ return;
+ }
+ int f4() {
+ return 0;
+ }
+
+ {
+ return;
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SerializableStuff.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SerializableStuff.java
new file mode 100644
index 000000000000..d339899e8e20
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SerializableStuff.java
@@ -0,0 +1,77 @@
+// Serializable/externalizable specific
+
+import java.io.*;
+class a implements Serializable {
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ if (stream == null) throw new IOException();
+ if (stream == null) throw new ClassNotFoundException();
+ }
+
+ private void readObjectNoData() throws ObjectStreamException {
+ if (this == null) throw new ObjectStreamException(){};
+ }
+
+
+ private Object readResolve()
+ throws ObjectStreamException {
+ if (this == null) throw new ObjectStreamException(){};
+ return null;
+ }
+
+ private Object writeReplace() { return null; }
+ private void writeObject(ObjectOutputStream stream) { if (stream==null) return; }
+
+
+}
+
+class b {
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ if (stream == null) throw new IOException();
+ if (stream == null) throw new ClassNotFoundException();
+ }
+
+ private void readObjectNoData() throws ObjectStreamException {
+ if (this == null) throw new ObjectStreamException(){};
+ }
+
+
+ private Object readResolve()
+ throws ObjectStreamException {
+ if (this == null) throw new ObjectStreamException(){};
+ return null;
+ }
+
+ private Object writeReplace() { return null; }
+ private void writeObject(ObjectOutputStream stream) { if (stream==null) return; }
+}
+
+////////////////////////////
+abstract class e implements Externalizable {
+}
+class eImpl extends e {
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+}
+class eImpl1 extends e {
+ private eImpl1() {}
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+}
+class eImpl2 extends e {
+ public eImpl2(int i) {
+ System.out.print(i);
+ }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SillyAssignment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SillyAssignment.java
new file mode 100644
index 000000000000..8c270c2198e3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/SillyAssignment.java
@@ -0,0 +1,37 @@
+// silly asignment
+import javax.swing.*;
+
+class a {
+ int f;
+ JPanel fpanel;
+
+ void f(int i) {
+
+ i = i;
+ }
+
+ void f2() {
+ this.f = f;
+ a.this.f = f;
+ f = this.f;
+ }
+
+ void f3(Object o) {
+ int i = 0;
+ i = i;
+ i = (int)i;
+ o = ((Object)(o));
+ }
+ void f4() {
+ fpanel.getSize().height = this.fpanel.getSize().height; // not silly. Are you sure you can bet getSize() has no side effects?
+ }
+
+ void cf1() {
+ JPanel a = new JPanel(), b = new JPanel();
+ a.getSize().height = b.getSize().height; // not silly!
+ }
+
+ void cf2(a aa) {
+ aa.f = f;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java
new file mode 100644
index 000000000000..2229311ad290
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java
@@ -0,0 +1,132 @@
+// method override
+import java.io.*;
+import java.net.*;
+
+public class a extends a1 {
+ public static void f() { }
+ public void f1() { }
+}
+class a1 {
+ public void f() {}
+ public static void f1() {}
+}
+
+interface i {
+ void f1();
+}
+
+class c_a1_i extends a1 implements i {
+}
+
+interface ii {
+ int f();
+}
+
+abstract class c_a1_ii extends a1 implements ii {
+}
+
+interface i2 {
+ int f1();
+}
+interface i3 extends i, i2 {
+}
+
+class weak {
+ void f1() {}
+}
+class a2 extends weak implements i {
+}
+
+class a3 {
+ protected void f1() {}
+}
+class a4 extends a3 implements i {
+// public void f1() {}
+}
+class a5 extends a3 implements i {
+ // if we override suspicious method, its OK
+ public void f1() {}
+}
+
+
+
+// deep inherit
+class da1 { void f() {} }
+class da2 extends da1 { void f() {} }
+class da3 extends da2 {}
+
+
+
+
+interface MyInterface
+{
+ public void myMethod();
+}
+class MyInterfaceImpl implements MyInterface
+{
+ public static void myMethod() { /* implementation goes here */ }
+
+ private static String toString() {
+ return null;
+ }
+
+}
+
+
+
+// Sun-style inheritance
+public class Sunc {
+ protected void f() {}
+}
+public class Suncc extends Sunc {
+ public void f() {}
+}
+public interface Suni {
+ public void f();
+}
+class Sunccc extends Suncc implements Suni {
+}
+
+// override static
+class StA {
+ public static StA createInstance() {
+ return new StA();
+ }
+}
+class StB extends StA {
+ public static String createInstance() {
+ return null;
+ }
+}
+
+////////
+class Foo {
+ protected static void foo(String s) {}
+}
+public class Bar extends Foo{
+ private static void foo(String s) {}
+}
+
+
+///////////// IDEADEV-41779
+class A {
+ public static C C() { return new C(); }
+}
+class B extends A {
+}
+class C extends B {
+ public C() {}
+}
+///////////////////////////
+class Z1 {
+ public static final void doItBaby() {
+ System.out.println("Hello, diar A");
+ }
+}
+
+class Z2 extends Z1 {
+ public static void doItBaby() {
+ System.out.println("Hello, diar B");
+ }
+}
+///////////////////
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StringSwitchLabels.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StringSwitchLabels.java
new file mode 100644
index 000000000000..9b8f99b1946d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StringSwitchLabels.java
@@ -0,0 +1,23 @@
+public class Test {
+ private static final String BAZ = "baz";
+
+ private void stringSwitch() {
+ final String bar = "bar";
+ String key = "key";
+ switch (key) {
+ case "": {
+ System.out.println("Nothing");
+ break;
+ }
+ case "foo":
+ case bar:
+ case BAZ: {
+ System.out.println("Matched key");
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Suppressed.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Suppressed.java
new file mode 100644
index 000000000000..9ee533fa0faf
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Suppressed.java
@@ -0,0 +1,8 @@
+public class Suppressed {
+ private static final String UNUSED_DECLARATION = "UnusedDeclaration";
+
+ @java.lang.SuppressWarnings(UNUSED_DECLARATION)
+ public static void main(String[] args) {
+ int i = 0;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledMessingWithFinally.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledMessingWithFinally.java
new file mode 100644
index 000000000000..de6502774d09
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnhandledMessingWithFinally.java
@@ -0,0 +1,84 @@
+// unhandled exception when messing with finally block
+
+import java.io.*;
+class a {
+ void f1(int i) {
+ try {
+ new FileReader("");
+ }
+ finally {
+ throw new ClassNotFoundException();
+ }
+ }
+
+ void f2(int i) {
+ try {
+ new FileReader("");
+ }
+ finally {
+ if (i==4) throw new ClassNotFoundException();
+ }
+ }
+
+ void f3(int i) {
+ try {
+ new FileReader("");
+ }
+ finally {
+ if (i==1) return;
+ }
+ }
+
+ void f4(int i) {
+ try {
+ new FileReader("");
+ }
+ finally {
+ if (i==1) throw new FileNotFoundException();
+ }
+ }
+
+ void cf1(int i) {
+ try {
+ new FileReader("");
+ }
+ catch (FileNotFoundException e) {
+ }
+ finally {
+ if (1==1) return;
+ }
+ }
+
+ void cf2(int i) {
+ try {
+ new FileReader("");
+ }
+ finally {
+ while (1==1) return;
+ }
+ }
+ void foo(OutputStream out, byte[] data) throws IOException {
+ out.write(data);
+ }
+
+ public void swallow() {
+ try {
+ throw new Exception("Hello World! I'm Checked Exception and must be declared!");
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ return;
+ }
+ }
+ public void spitout() {
+ try {
+ throw new Exception("Hello World! I'm Checked Exception and must be declared!");
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ //return;
+ }
+ }
+
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java
new file mode 100644
index 000000000000..9b419b3b4b08
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unreachable.java
@@ -0,0 +1,359 @@
+// unreachables
+import java.io.*;
+import java.net.*;
+public class a {
+interface ii {}
+
+ { // initializer
+ try {
+ throw new Exception();
+ int i = 5;
+ }
+ catch (Exception e) {
+ }
+ }
+
+
+ int f1() throws Exception {
+ return 2;
+ return 5;
+ }
+ int f2(int i) throws Exception {
+ if (i==2) return 2;
+ throw new Exception();
+ return 5;
+ }
+ int f3(int i) throws Exception {
+ for (;;) return 2;
+ return 5;
+ }
+ int f4(int i) throws Exception {
+ try {
+ if (i==3) throw new Exception();
+ return 4;
+ } finally {
+ if (i==6) return 9;
+ }
+ return 5;
+ }
+
+ void f5()
+ {
+ try {
+ } catch (Error e) {
+ throw e;
+ ;
+ }
+ }
+
+ void f6() {
+ try {
+ }
+ finally {
+ return;
+ ;
+ }
+ }
+
+ void f7(RuntimeException e) {
+ for (;;) {
+ if (e==null) {
+ return;
+ break;
+ }
+ }
+ }
+ void f8(RuntimeException e,int i,int j,int k,int l) {
+ for (;;) {
+ if (e==null) {
+ return;
+ f8(e,i,j,k,l);
+ }
+ }
+ }
+ void f9(RuntimeException e,int i,int j,int k,int l) {
+ for (;;) {
+ if (e==null) {
+ return;
+ throw e;
+ }
+ }
+ }
+ class Af10 {
+ int f() {
+ return 0;
+ new Af10();
+ }
+
+ }
+ class Af11 {
+ int f() {
+ return 0;
+ int k;
+ }
+ void test() {
+ int i;
+ return;
+ assert i == i;
+ }
+ }
+
+
+
+ int cf1(int i) throws Exception {
+ if (i==2) return 2;
+ for (int k=0;1==1;k++) break;
+ try {
+ i = 5;
+ }
+ catch (Error e) {
+ if (i==5) return 2;
+ }
+ catch (RuntimeException e) {
+ }
+ catch (Throwable e) {
+ }
+
+ return 5;
+ }
+
+ int cf2(int i) throws Exception {
+ switch (i) {
+ case 1: return 4;
+ }
+ return 5;
+ }
+ void cf3() {
+ if (false) {
+ int i = 5;
+ }
+ while (true) { break; }
+ if (true) {
+ int i = 4;
+ }
+ else {
+ int i = 6;
+ }
+ }
+ void cf4() throws java.net.SocketException {
+ try {
+ bind();
+ } catch (java.net.SocketException se) {
+ throw se;
+ } catch(java.io.IOException e) {
+ throw new java.net.SocketException(e.getMessage());
+ }
+ }
+ void bind() throws java.net.SocketException {}
+
+
+ void cf5() {
+ try {
+ } catch(Exception e) {
+
+ }
+ }
+
+ void cf6() {
+ if (true || true) {
+ } else {
+ System.out.println("hi");
+ }
+ }
+
+
+ static boolean g() {
+ return true;
+ }
+ public static void main(String[] args) {
+ boolean b=false && g();
+ System.out.println("b = "+b);
+ }
+
+
+
+ void cf7() {
+ try {
+ } finally {
+ try {
+ } finally {
+ }
+ try {
+ } finally {
+ try {
+ } finally {
+ }
+ try {
+ } finally {
+ try {
+ } finally {
+ try {
+ } finally {
+ try {
+ } finally {
+ try {
+ } finally {
+ }
+ }
+ }
+ }
+ try {
+ try {
+ } finally {
+ }
+ } finally {
+ }
+ }
+ }
+ }
+ ;
+ }
+
+ void cf8() {
+ class Test01
+ {
+
+ public int testMethod()
+ {
+ try
+ {
+ throw new Exception("test");
+ }
+ catch(Exception e)
+ {
+ try
+ {
+ throw new Exception("test");
+ }
+ catch(Exception ee)
+ {}
+ finally
+ {}
+ }
+ finally
+ {
+
+ try
+ {
+ throw new Exception("test");
+ }
+ catch(Exception e)
+ {}
+ finally
+ {}
+ }
+ return 0;
+ }
+ }
+ }
+
+ void cf9() {
+ // should not try to compute constant expression within assert
+ // since assertions can be disabled/enabled at any moment via JVM flags
+ assert true;
+ assert false;
+ final int i;
+ if (0==1) {
+ i = 9;
+ }
+ else {
+ i = 0;
+ }
+ }
+
+ void cf10() {
+ int k = 0;
+ switch (k) {
+ }
+ }
+
+
+ private Exception getException()
+ {
+ return new java.io.IOException();
+ }
+
+ public void cf11()
+ {
+ try {
+ throw getException();
+ }
+ catch (java.io.IOException e) {
+ e.printStackTrace(); // IDEA claims this to be "Unreachable statement"//
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ //////////////////////////
+ public void cf12() {
+ try {
+ try {
+ } finally {
+ doit();
+ }
+ } catch (Excep1 e) {
+ String error = "RollbackException";
+ } catch (Excep2 e) {
+ String error = "HeuristicRollbackException";
+ } catch (Excep3 e) {
+ String error = "SystemException";
+ } catch (IllegalStateException e) {
+ String error = "IllegalStateException";
+ } catch (RuntimeException e) {
+ String error = "RuntimeException";
+ }
+ }
+
+ private void doit() throws Excep1, Excep2, Excep3{
+ //To change body of created methods use Options | File Templates.
+ }
+
+ class Excep1 extends Exception {}
+ class Excep2 extends Exception {}
+ class Excep3 extends Exception {}
+
+
+
+
+ public void cf13() throws Exception {
+ while (true) {
+ try {
+ cf13();
+ } finally {
+ continue;
+ }
+ }
+ }
+
+}
+
+
+class NestedFinallyTest {
+ void ftest4() {
+ try {
+ }
+ finally {
+ try {
+ }
+ finally {
+ try {
+ }
+ finally {
+ try {
+ }
+ catch (Throwable t4) {
+ }
+ }
+ }
+ }
+ ftest4();
+ }
+}
+
+
+
+
+
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java
new file mode 100644
index 000000000000..bcbcd279de6d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/Unused.java
@@ -0,0 +1,46 @@
+public class a extends Exception {
+ private a(String s) {
+ super(s);
+ }
+}
+
+class s extends Exception {
+ private s(String s) {
+ super(s);
+ }
+ public s create() {
+ return new s("");
+ }
+}
+
+class PrivateClassTest {
+ private static class Test1 {
+ // Complains that this constructor is never used
+ private Test1 () {}
+
+ private Test1 (String s) {
+ System.out.println(s);
+ }
+ }
+
+ private static class Test2 extends Test1 {
+ // Complains that no default constructor is available
+ public Test2 () {
+ }
+
+ // Complains that the relevant constructor has private access
+ public Test2 (String s) {
+ super (s);
+ }
+ }
+ public static void main(String[] args) {
+ System.out.println(new Test2());
+ }
+
+ private void f(boolean b,
+ int param) {
+ if (b) {
+ f(b, param);
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java
new file mode 100644
index 000000000000..9f3a7b47cbb8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers.java
@@ -0,0 +1,19 @@
+public class XXX {
+ void fffff(){}
+ public void asdfaffffff(){}
+ protected void dasklfjhsad(){}
+
+ String asdfadsf;
+ public String asdasdfadsf;
+ static class sasdfasdfasd {}
+
+ public XXX() {}
+
+
+ // overloaded
+ void fffff(String i){i.hashCode();}
+ {
+ fffff(null);
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java
new file mode 100644
index 000000000000..b7ae475f9e66
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedNonPrivateMembers2.java
@@ -0,0 +1,9 @@
+public class WithMain {
+
+ public static void main(String[] args){
+
+ }
+
+ public void myTestMethod(){}
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethod.java
new file mode 100644
index 000000000000..2af80d1fadc8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethod.java
@@ -0,0 +1,19 @@
+class Sup {
+ protected void f(int i){}
+}
+class Foo extends Sup {
+ public void foo(int i){}
+ public void g(int i){}
+ protected void f(int i){}
+}
+class Sub extends Foo {
+ public void g(int i){}
+}
+
+
+interface fff {
+ void f(int ggggg);//
+}
+abstract class ab {
+ public abstract void f(int ggggg);//
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethodDisabled.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethodDisabled.java
new file mode 100644
index 000000000000..994ccbab4a9d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/UnusedParamsOfPublicMethodDisabled.java
@@ -0,0 +1,19 @@
+class Sup {
+ protected void f(int i){}
+}
+class Foo extends Sup {
+ public void foo(int i){}
+ public void g(int i){}
+ protected void f(int i){}
+}
+class Sub extends Foo {
+ public void g(int i){}
+}
+
+
+interface fff {
+ void f(int ggggg);//
+}
+abstract class ab {
+ public abstract void f(int ggggg);//
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefined.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefined.java
new file mode 100644
index 000000000000..f549f26717cd
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefined.java
@@ -0,0 +1,34 @@
+class s {
+ void f() {
+ int i;
+ int i;
+ }
+ void f1() {
+ int i;
+ {
+ int i;
+ }
+ }
+ void f2() {
+ int i;
+ class ss
+ {
+ int i;
+ }
+ }
+
+ int f;
+ int f;
+ void f3() {
+ int f;
+ }
+
+ public void tutu(String e) {
+ try {
+ Integer.parseInt("3");
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefinedTop.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefinedTop.java
new file mode 100644
index 000000000000..e50eb1dc49d2
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/VariableAlreadyDefinedTop.java
@@ -0,0 +1,25 @@
+class s {
+ void f() {
+ int i;
+ int i;
+ }
+ void f1() {
+ int i;
+ {
+ int i;
+ }
+ }
+ void f2() {
+ int i;
+ class ss
+ {
+ int i;
+ }
+ }
+
+ int f;
+ int f;
+ void f3() {
+ int f;
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java
new file mode 100644
index 000000000000..0a9a173f2347
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/XXX.java
@@ -0,0 +1,5 @@
+import java.io.*;
+
+public class x {
+ static {int i;}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a10.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a10.java
new file mode 100644
index 000000000000..a2514171a827
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a10.java
@@ -0,0 +1,31 @@
+// string literal
+public class a {
+ char c1 = '';
+ char c2 = '\dd';
+ char c4 = 'xxx';
+ char c5 = '\78';
+ char c6 = '\78';
+
+ char[] cA = new char[] { 'd','\b','\f','\n','\r'
+ ,'\t','"','\\',' ','\u1234','\uFFFF'
+ , '\7', '\77', '\345', '\0'};
+
+ String s1 = "\xd";
+ String s11= "\udX";
+ String s12= "c:\TEMP\test.jar";
+ String s3 = "";
+ String s4 = "\u0000";
+
+ String s5 = "\u000d";
+ String s6 = "\u000a";
+ char c7 = '\u000d';
+ char c8 = '\u000a';
+
+
+ void foo(String a) {
+ foo("aaa
+ );
+ }
+
+
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a11.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a11.java
new file mode 100644
index 000000000000..1edc0de72d6c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a11.java
@@ -0,0 +1,106 @@
+//statics in inner
+public class a {
+
+ static final Number x = null;
+ static final int ix = x== null ? 4 : 3;
+
+ class ic {
+ static
+ int i;
+
+ static
+ final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
+
+ static
+ final int f2 = x instanceof Integer ? 1 : 0;
+
+ static
+ class a_ic_c {}
+
+ interface a_ic_i {}
+ static interface a_ic_i2 {}
+
+ static
+ int a_ic_m(String s) { return 0; }
+
+ // static initializer
+ static
+ {}
+ }
+
+
+ interface ii {
+ static int i = 9;
+ void f();
+ // since nested interface is implicitly static:
+ static class ii_c {}
+ }
+
+ // static inside class inside code block
+ void f() {
+ class ic2 {
+ static
+ int i;
+
+ static
+ final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
+
+ static
+ final int f2 = x instanceof Integer ? 1 : 0;
+
+ static
+ class a_ic_c2 {}
+
+ static
+ int a_ic_m2(String s) { return 0; }
+ // static initializer
+ static
+ {}
+ }
+ }
+
+ void f1()
+ {
+ new a() {
+ static
+ int i;
+
+ static
+ final int f1 = 3 < 4 ? (a.ix==5 ? 1 : 3) / 4 + 18 : 0;
+
+ // its not a compile time constant
+ static
+ final Object o = null;
+
+ static
+ final int f2 = x instanceof Integer ? 1 : 0;
+
+ static
+ class a_ic_c2 {}
+
+ static
+ int a_ic_m2(String s) { return 0; }
+ // static initializer
+ static
+ {}
+ };
+ }
+
+ // local interface
+ class cc {
+ void f() {
+ interface i {}
+ }
+ void ff() {
+ class inn {
+ interface i {}
+ }
+ }
+
+ Object o = new Runnable() {
+ interface i {}
+ public void run() {}
+ };
+ }
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a16.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a16.java
new file mode 100644
index 000000000000..8622224336d0
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a16.java
@@ -0,0 +1,102 @@
+// casts
+public class a {
+ void f(i ii) {
+ boolean b;
+ b = 2 instanceof a;
+ b = null instanceof int;
+ b = (c3)null instanceof Boolean;
+
+ b = ii instanceof i;
+ b = ((c2)ii) instanceof c4;
+ b = null instanceof a;
+ b = ii instanceof c3;
+ b = Boolean.valueOf("true") instanceof Boolean;
+ b = new Long(3) instanceof Number;
+ b = this instanceof a;
+ b = ii instanceof a;
+ b = this instanceof i;
+
+
+ // casts
+ c2 c2i = null;
+ c3 c3i = null;
+ c4 c4i = null;
+ Object o;
+ c4i = (c4) this;
+ o = (boolean) c2i;
+ o = (Integer) c3i;
+ o = (a) c2i;
+ o = (int) c3i;
+
+ o = (a) ii;
+ o = (i) c4i; //cast to interface
+ o = (c3) c2i;
+ o = (c3) c3i;
+ o = (c3) c4i;
+ o = (Object) ii;
+ o = (iunrelated) ii;
+ o = (iunrelated) c2i;
+ o = (c4) c2i;
+ o = (c4) ii;
+ o = (c5) ii;
+
+ int[] ai = null;
+ o = (byte[])ai;
+ o = (double[])ai;
+ c3[] ac3i = null;
+ o = ac3i;
+ o = (c4[])ac3i;
+ o = (i[])ac3i;
+ Object[] results = null;
+ int index = ((Integer) results).intValue();
+
+
+ // arrays and Serializable/Cloneable/Object
+ int[] ai2 = (int[])o;
+ Cloneable cloneable = null;
+ ai2 = (int[]) cloneable;
+ java.io.Serializable serializable = null;
+ ai2 = (int[]) serializable;
+
+ }
+
+}
+
+interface iunrelated {}
+interface i {}
+class c2 implements i {
+ public c2() {}
+ public void f() {}
+ protected void g() {}
+}
+
+class c3 extends c2 {
+ protected c3() {}
+ private int g(int k) { return 0; }
+}
+
+final class c4 extends c3 {
+ private c4() {
+ int[] a=new int[3];
+ Cloneable s=a;
+ java.io.Serializable ss = a;
+ }
+}
+final class c5 {}
+
+// clashing interfaces
+interface A {
+ void g();
+}
+interface B {
+ int g();
+}
+interface BB extends B {
+}
+class Foo {
+ void f(A a) {
+ B b = (B) a;
+ BB b2 = (BB) a;
+ A a2 = (A) b2;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a18.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a18.java
new file mode 100644
index 000000000000..5a3b705d1aeb
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a18.java
@@ -0,0 +1,1059 @@
+//Missing return statement
+import java.io.*;
+import java.net.*;
+public class a {
+interface ii {}
+
+
+
+ int f1() throws Exception {
+ }
+
+ Object f2(int i) throws Exception {
+ if (i == 0) return null;
+ }
+
+ Object f3(int i) throws Exception {
+ while (i == 0) return null;
+ }
+
+ Object f4(int i) throws Exception {
+ switch (i) {
+ case 1: return null;
+ }
+ }
+
+ Object f5(int i) throws Exception {
+ if (i==2) return null;
+ else if (i != 2) return null;
+ }
+
+ Object f6(int i) throws Exception {
+ if (true) return null;
+ }
+
+ int f7(int i) {
+ try {
+ if (i==2) return 4;
+ else throw new IllegalArgumentException();
+ } catch (Exception e) {
+ }
+ }
+
+ int f8(int i) {
+ try {
+ //throw new Error();
+ }
+ finally {
+ try {
+ //throw new Exception();
+ }
+ catch (Exception e) {
+ return 5;
+ }
+ }
+ }
+
+ int cf1(int i) {
+ return 0;
+ }
+ int cf2(int i) {
+ if (i==2) return 0;
+ else if (i==4) return -1;
+ else return 2;
+ }
+ int cf3(int i) {
+ return i==2 ? 3 : 5;
+ }
+ int cf4(int i) {
+ switch (i) {
+ case 1: return 4;
+ case 3: return 6;
+ default: return 5;
+ }
+ }
+ int cf5(int i) {
+ if (i>1) {
+ if (i==4) return 0;
+ else return i==3 ? 2 : 0;
+ }
+ else return 2;
+ }
+ int cf6(int i) {
+ return cf4(i+1);
+ }
+
+ int cf7(int i) throws Exception {
+ try {
+ throw new Exception();
+ } catch(Error e) {
+ return 3;
+ } finally {
+ return 2;
+ }
+
+ }
+
+ int cf8(int i) throws Exception {
+ try {
+ return 2;
+ } finally {
+ return 4;
+ }
+ }
+ int cf9(int i) throws Exception {
+ try {
+ i = 5;
+ } finally {
+ throw new Exception();
+ }
+ }
+
+ int cf10(int i) {
+
+ while (true)
+ return 0;
+ }
+ int cf11(int i) {
+
+ // commented out reference
+ // does not work when running under JRE
+
+ while (a.co != 2 && 1+3/2-1 + (int)1.5 + 2%2 == 2 /* && 0x7fffffff == Integer.MAX_VALUE */ && ('c' & 0x00) == 0)
+ return 0;
+ }
+ private static final int co = 1/2 + 1;
+ int cf12(int i) {
+
+ for (int k=0; (0xf0 | 0x0f) == 0xff && false != true && co == 1;k++)
+ return 0;
+ }
+
+
+ int cf13() {
+ try {
+ try {
+ throw new IllegalArgumentException();
+ //throw new java.io.IOException();
+ } catch (IllegalArgumentException e) {
+ return 3;
+ }
+ finally {
+ throw new java.io.IOException();
+ }
+
+ } catch (java.io.IOException ee) {
+ return 88;
+ }
+ }
+
+ int cf14() {
+ try {
+ cf13();
+ return 13;
+ } finally {
+ cf13();
+ }
+ }
+
+ int cf15() {
+ try {
+ int i=0;
+ return i;
+ } catch (Exception e) {
+ } finally {
+ }
+ return 0;
+ }
+ int cf16() {
+ try {
+ if ( ! (1==3)) {
+ return 0;
+ }
+ } finally {
+ // Restore the current position of the other DynAny
+ }
+ return 1;
+ }
+
+ int cf17() {
+ try {
+ try {
+ return 0;
+ } finally {
+ }
+ } finally {
+ }
+ }
+ int cf18(int i) {
+ int k;
+ try {
+ if (i==4) return 0;
+ k = 4;
+ } finally {
+ }
+ return k;
+ }
+
+
+ void cf19() {
+
+ try {
+
+ try {
+ }
+ finally {
+ }
+ return ;
+ }
+ catch (Exception e) {
+ }
+ }
+
+}
+
+ class a2 {
+interface ii {}
+
+
+
+ int f1() throws Exception {
+ }
+
+ Object f2(int i) throws Exception {
+ if (i == 0) return null;
+ }
+
+ Object f3(int i) throws Exception {
+ while (i == 0) return null;
+ }
+
+ Object f4(int i) throws Exception {
+ switch (i) {
+ case 1: return null;
+ }
+ }
+
+ Object f5(int i) throws Exception {
+ if (i==2) return null;
+ else if (i != 2) return null;
+ }
+
+ Object f6(int i) throws Exception {
+ if (true) return null;
+ }
+
+ int f7(int i) {
+ try {
+ if (i==2) return 4;
+ else throw new IllegalArgumentException();
+ } catch (Exception e) {
+ }
+ }
+
+ int f8(int i) {
+ try {
+ //throw new Error();
+ }
+ finally {
+ try {
+ //throw new Exception();
+ }
+ catch (Exception e) {
+ return 5;
+ }
+ }
+ }
+
+ int cf1(int i) {
+ return 0;
+ }
+ int cf2(int i) {
+ if (i==2) return 0;
+ else if (i==4) return -1;
+ else return 2;
+ }
+ int cf3(int i) {
+ return i==2 ? 3 : 5;
+ }
+ int cf4(int i) {
+ switch (i) {
+ case 1: return 4;
+ case 3: return 6;
+ default: return 5;
+ }
+ }
+ int cf5(int i) {
+ if (i>1) {
+ if (i==4) return 0;
+ else return i==3 ? 2 : 0;
+ }
+ else return 2;
+ }
+ int cf6(int i) {
+ return cf4(i+1);
+ }
+
+ int cf7(int i) throws Exception {
+ try {
+ throw new Exception();
+ } catch(Error e) {
+ return 3;
+ } finally {
+ return 2;
+ }
+
+ }
+
+ int cf8(int i) throws Exception {
+ try {
+ return 2;
+ } finally {
+ return 4;
+ }
+ }
+ int cf9(int i) throws Exception {
+ try {
+ i = 5;
+ } finally {
+ throw new Exception();
+ }
+ }
+
+ int cf10(int i) {
+
+ while (true)
+ return 0;
+ }
+ private static final int co = 1/2 + 1;
+ int cf12(int i) {
+
+ for (int k=0; (0xf0 | 0x0f) == 0xff && false != true && co == 1;k++)
+ return 0;
+ }
+
+
+ int cf13() {
+ try {
+ try {
+ throw new IllegalArgumentException();
+ //throw new java.io.IOException();
+ } catch (IllegalArgumentException e) {
+ return 3;
+ }
+ finally {
+ throw new java.io.IOException();
+ }
+
+ } catch (java.io.IOException ee) {
+ return 88;
+ }
+ }
+
+ int cf14() {
+ try {
+ cf13();
+ return 13;
+ } finally {
+ cf13();
+ }
+ }
+
+ int cf15() {
+ try {
+ int i=0;
+ return i;
+ } catch (Exception e) {
+ } finally {
+ }
+ return 0;
+ }
+ int cf16() {
+ try {
+ if ( ! (1==3)) {
+ return 0;
+ }
+ } finally {
+ // Restore the current position of the other DynAny
+ }
+ return 1;
+ }
+
+ int cf17() {
+ try {
+ try {
+ return 0;
+ } finally {
+ }
+ } finally {
+ }
+ }
+ int cf18(int i) {
+ int k;
+ try {
+ if (i==4) return 0;
+ k = 4;
+ } finally {
+ }
+ return k;
+ }
+
+
+ void cf19() {
+
+ try {
+
+ try {
+ }
+ finally {
+ }
+ return ;
+ }
+ catch (Exception e) {
+ }
+ }
+
+}
+
+
+ class a3 {
+interface ii {}
+
+
+
+ int f1() throws Exception {
+ }
+
+ Object f2(int i) throws Exception {
+ if (i == 0) return null;
+ }
+
+ Object f3(int i) throws Exception {
+ while (i == 0) return null;
+ }
+
+ Object f4(int i) throws Exception {
+ switch (i) {
+ case 1: return null;
+ }
+ }
+
+ Object f5(int i) throws Exception {
+ if (i==2) return null;
+ else if (i != 2) return null;
+ }
+
+ Object f6(int i) throws Exception {
+ if (true) return null;
+ }
+
+ int f7(int i) {
+ try {
+ if (i==2) return 4;
+ else throw new IllegalArgumentException();
+ } catch (Exception e) {
+ }
+ }
+
+ int f8(int i) {
+ try {
+ //throw new Error();
+ }
+ finally {
+ try {
+ //throw new Exception();
+ }
+ catch (Exception e) {
+ return 5;
+ }
+ }
+ }
+
+ int cf1(int i) {
+ return 0;
+ }
+ int cf2(int i) {
+ if (i==2) return 0;
+ else if (i==4) return -1;
+ else return 2;
+ }
+ int cf3(int i) {
+ return i==2 ? 3 : 5;
+ }
+ int cf4(int i) {
+ switch (i) {
+ case 1: return 4;
+ case 3: return 6;
+ default: return 5;
+ }
+ }
+ int cf5(int i) {
+ if (i>1) {
+ if (i==4) return 0;
+ else return i==3 ? 2 : 0;
+ }
+ else return 2;
+ }
+ int cf6(int i) {
+ return cf4(i+1);
+ }
+
+ int cf7(int i) throws Exception {
+ try {
+ throw new Exception();
+ } catch(Error e) {
+ return 3;
+ } finally {
+ return 2;
+ }
+
+ }
+
+ int cf8(int i) throws Exception {
+ try {
+ return 2;
+ } finally {
+ return 4;
+ }
+ }
+ int cf9(int i) throws Exception {
+ try {
+ i = 5;
+ } finally {
+ throw new Exception();
+ }
+ }
+
+ int cf10(int i) {
+
+ while (true)
+ return 0;
+ }
+ private static final int co = 1/2 + 1;
+ int cf12(int i) {
+
+ for (int k=0; (0xf0 | 0x0f) == 0xff && false != true && co == 1;k++)
+ return 0;
+ }
+
+
+ int cf13() {
+ try {
+ try {
+ throw new IllegalArgumentException();
+ //throw new java.io.IOException();
+ } catch (IllegalArgumentException e) {
+ return 3;
+ }
+ finally {
+ throw new java.io.IOException();
+ }
+
+ } catch (java.io.IOException ee) {
+ return 88;
+ }
+ }
+
+ int cf14() {
+ try {
+ cf13();
+ return 13;
+ } finally {
+ cf13();
+ }
+ }
+
+ int cf15() {
+ try {
+ int i=0;
+ return i;
+ } catch (Exception e) {
+ } finally {
+ }
+ return 0;
+ }
+ int cf16() {
+ try {
+ if ( ! (1==3)) {
+ return 0;
+ }
+ } finally {
+ // Restore the current position of the other DynAny
+ }
+ return 1;
+ }
+
+ int cf17() {
+ try {
+ try {
+ return 0;
+ } finally {
+ }
+ } finally {
+ }
+ }
+ int cf18(int i) {
+ int k;
+ try {
+ if (i==4) return 0;
+ k = 4;
+ } finally {
+ }
+ return k;
+ }
+
+
+ void cf19() {
+
+ try {
+
+ try {
+ }
+ finally {
+ }
+ return ;
+ }
+ catch (Exception e) {
+ }
+ }
+
+}
+
+
+
+ class a4 {
+interface ii {}
+
+
+
+ int f1() throws Exception {
+ }
+
+ Object f2(int i) throws Exception {
+ if (i == 0) return null;
+ }
+
+ Object f3(int i) throws Exception {
+ while (i == 0) return null;
+ }
+
+ Object f4(int i) throws Exception {
+ switch (i) {
+ case 1: return null;
+ }
+ }
+
+ Object f5(int i) throws Exception {
+ if (i==2) return null;
+ else if (i != 2) return null;
+ }
+
+ Object f6(int i) throws Exception {
+ if (true) return null;
+ }
+
+ int f7(int i) {
+ try {
+ if (i==2) return 4;
+ else throw new IllegalArgumentException();
+ } catch (Exception e) {
+ }
+ }
+
+ int f8(int i) {
+ try {
+ //throw new Error();
+ }
+ finally {
+ try {
+ //throw new Exception();
+ }
+ catch (Exception e) {
+ return 5;
+ }
+ }
+ }
+
+ int cf1(int i) {
+ return 0;
+ }
+ int cf2(int i) {
+ if (i==2) return 0;
+ else if (i==4) return -1;
+ else return 2;
+ }
+ int cf3(int i) {
+ return i==2 ? 3 : 5;
+ }
+ int cf4(int i) {
+ switch (i) {
+ case 1: return 4;
+ case 3: return 6;
+ default: return 5;
+ }
+ }
+ int cf5(int i) {
+ if (i>1) {
+ if (i==4) return 0;
+ else return i==3 ? 2 : 0;
+ }
+ else return 2;
+ }
+ int cf6(int i) {
+ return cf4(i+1);
+ }
+
+ int cf7(int i) throws Exception {
+ try {
+ throw new Exception();
+ } catch(Error e) {
+ return 3;
+ } finally {
+ return 2;
+ }
+
+ }
+
+ int cf8(int i) throws Exception {
+ try {
+ return 2;
+ } finally {
+ return 4;
+ }
+ }
+ int cf9(int i) throws Exception {
+ try {
+ i = 5;
+ } finally {
+ throw new Exception();
+ }
+ }
+
+ int cf10(int i) {
+
+ while (true)
+ return 0;
+ }
+ private static final int co = 1/2 + 1;
+ int cf12(int i) {
+
+ for (int k=0; (0xf0 | 0x0f) == 0xff && false != true && co == 1;k++)
+ return 0;
+ }
+
+
+ int cf13() {
+ try {
+ try {
+ throw new IllegalArgumentException();
+ //throw new java.io.IOException();
+ } catch (IllegalArgumentException e) {
+ return 3;
+ }
+ finally {
+ throw new java.io.IOException();
+ }
+
+ } catch (java.io.IOException ee) {
+ return 88;
+ }
+ }
+
+ int cf14() {
+ try {
+ cf13();
+ return 13;
+ } finally {
+ cf13();
+ }
+ }
+
+ int cf15() {
+ try {
+ int i=0;
+ return i;
+ } catch (Exception e) {
+ } finally {
+ }
+ return 0;
+ }
+ int cf16() {
+ try {
+ if ( ! (1==3)) {
+ return 0;
+ }
+ } finally {
+ // Restore the current position of the other DynAny
+ }
+ return 1;
+ }
+
+ int cf17() {
+ try {
+ try {
+ return 0;
+ } finally {
+ }
+ } finally {
+ }
+ }
+ int cf18(int i) {
+ int k;
+ try {
+ if (i==4) return 0;
+ k = 4;
+ } finally {
+ }
+ return k;
+ }
+
+
+ void cf19() {
+
+ try {
+
+ try {
+ }
+ finally {
+ }
+ return ;
+ }
+ catch (Exception e) {
+ }
+ }
+
+}
+
+ class a5 {
+interface ii {}
+
+
+
+ int f1() throws Exception {
+ }
+
+ Object f2(int i) throws Exception {
+ if (i == 0) return null;
+ }
+
+ Object f3(int i) throws Exception {
+ while (i == 0) return null;
+ }
+
+ Object f4(int i) throws Exception {
+ switch (i) {
+ case 1: return null;
+ }
+ }
+
+ Object f5(int i) throws Exception {
+ if (i==2) return null;
+ else if (i != 2) return null;
+ }
+
+ Object f6(int i) throws Exception {
+ if (true) return null;
+ }
+
+ int f7(int i) {
+ try {
+ if (i==2) return 4;
+ else throw new IllegalArgumentException();
+ } catch (Exception e) {
+ }
+ }
+
+ int f8(int i) {
+ try {
+ //throw new Error();
+ }
+ finally {
+ try {
+ //throw new Exception();
+ }
+ catch (Exception e) {
+ return 5;
+ }
+ }
+ }
+
+ int f9(int i) {
+ if (i==1) return 0;
+ else assert false;
+ }
+
+
+
+ int cf1(int i) {
+ return 0;
+ }
+ int cf2(int i) {
+ if (i==2) return 0;
+ else if (i==4) return -1;
+ else return 2;
+ }
+ int cf3(int i) {
+ return i==2 ? 3 : 5;
+ }
+ int cf4(int i) {
+ switch (i) {
+ case 1: return 4;
+ case 3: return 6;
+ default: return 5;
+ }
+ }
+ int cf5(int i) {
+ if (i>1) {
+ if (i==4) return 0;
+ else return i==3 ? 2 : 0;
+ }
+ else return 2;
+ }
+ int cf6(int i) {
+ return cf4(i+1);
+ }
+
+ int cf7(int i) throws Exception {
+ try {
+ throw new Exception();
+ } catch(Error e) {
+ return 3;
+ } finally {
+ return 2;
+ }
+
+ }
+
+ int cf8(int i) throws Exception {
+ try {
+ return 2;
+ } finally {
+ return 4;
+ }
+ }
+ int cf9(int i) throws Exception {
+ try {
+ i = 5;
+ } finally {
+ throw new Exception();
+ }
+ }
+
+ int cf10(int i) {
+
+ while (true)
+ return 0;
+ }
+ private static final int co = 1/2 + 1;
+ int cf12(int i) {
+
+ for (int k=0; (0xf0 | 0x0f) == 0xff && false != true && co == 1;k++)
+ return 0;
+ }
+
+
+ int cf13() {
+ try {
+ try {
+ throw new IllegalArgumentException();
+ //throw new java.io.IOException();
+ } catch (IllegalArgumentException e) {
+ return 3;
+ }
+ finally {
+ throw new java.io.IOException();
+ }
+
+ } catch (java.io.IOException ee) {
+ return 88;
+ }
+ }
+
+ int cf14() {
+ try {
+ cf13();
+ return 13;
+ } finally {
+ cf13();
+ }
+ }
+
+ int cf15() {
+ try {
+ int i=0;
+ return i;
+ } catch (Exception e) {
+ } finally {
+ }
+ return 0;
+ }
+ int cf16() {
+ try {
+ if ( ! (1==3)) {
+ return 0;
+ }
+ } finally {
+ // Restore the current position of the other DynAny
+ }
+ return 1;
+ }
+
+ int cf17() {
+ try {
+ try {
+ return 0;
+ } finally {
+ }
+ } finally {
+ }
+ }
+ int cf18(int i) {
+ int k;
+ try {
+ if (i==4) return 0;
+ k = 4;
+ } finally {
+ }
+ return k;
+ }
+
+
+ void cf19() {
+
+ try {
+
+ try {
+ }
+ finally {
+ }
+ return ;
+ }
+ catch (Exception e) {
+ }
+ }
+ int cf20(boolean b1, boolean b2) {
+ do {
+ } while (b1 || b2);
+ return 0;
+ }
+
+ public boolean cf21() throws IOException {
+ try {
+ return geta();
+ }
+ catch(IOException e) {
+ throw new RuntimeException();
+ }
+ finally {
+ geta();
+ }
+ }
+ private boolean geta() throws IOException {
+ return true;
+ }
+
+ String complexAss(Object o, Object p) {
+ assert o != null && p != null;
+ return null;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22.java
new file mode 100644
index 000000000000..de0f4f0f6d6d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22.java
@@ -0,0 +1,150 @@
+// vars double initialization
+import java.io.*;
+import java.net.*;
+public class a21 {
+
+ void f1(int i) {
+ final int j;
+ j = 2;
+ j = 2;
+ }
+ void f2(int i) {
+ final int j;
+ if (i==3) j = 2;
+ else j = 5;
+ j = 2;
+ }
+ void f3(int i) {
+ final int j;
+ if (i==4) j = 2;
+ j = 2;
+ }
+ void f5(int i) {
+ final int j;
+ j = 2;
+ if (i==3) return;
+ j = 2;
+ }
+ void f6(int i) {
+ final int j;
+ switch (i) {
+ case 1: j = 2;
+ }
+ j = 2;
+ }
+ void f7(int i) {
+ final int j;
+ while (i < 4) {
+ j = 2;
+ final int ii = 4;
+ i+=ii;
+ }
+
+ }
+ void f8(String k) {
+ if (k != null) {
+ final String i;
+ if (k.equals("!")) i = "3";
+ if (k.equals("!")) i = "2";
+ }
+
+ }
+
+ void f9() {
+ final Object type;
+ try {
+ type = null;
+ }
+ catch (Exception e) {
+ type = null;
+ }
+ }
+
+ void f10() {
+ final int k;
+ if (false) {
+ k=0;
+ //< error descr="Variable 'k' might already have been assigned to">k< /error>=0;
+ }
+ }
+
+class Foo {
+ final int k;
+ Foo() {
+ k=0;
+ k=0;
+ }
+}
+
+
+
+
+ void cf1(int i) {
+ final int j;
+ final int j1 = 3;
+ j = 5;
+ final int unused;
+ final int j2;
+ if (j == 3) j2 = 4;
+ final int j3;
+ if (j==4) j3 = 5;
+ else j3 = 6;
+ final int j4 = j3 + 6;
+ final int j5;
+ while (i != 9) {
+ if (j == 8) {
+ j5 = 9;
+ break;
+ }
+ }
+ }
+
+ final boolean FB = true;
+
+ void cf2() {
+ final int k;
+ if (!FB) {
+ k = 4;
+ }
+ // < error descr="Variable 'k' might already have been assigned to">k< /error>=0;
+ }
+
+
+ // todo:
+ // in IDEA Variable 'b' might not have been initialized
+ // in javac: OK
+ /*
+ void f2() {
+ boolean b;
+ boolean c = true;
+ if (c && false) {
+ c = b;
+ }
+ }
+ */
+
+}
+
+
+class A {
+ final int k;
+ A() {
+ for (;;) {
+ k=0;
+ }
+ }
+}
+
+class Example {
+ public int method(boolean b) {
+ if (b) {
+ final int indent;
+ indent = 0;
+
+ return 0;
+ }
+ else {
+ new Runnable(){}
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22_1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22_1.java
new file mode 100644
index 000000000000..c3de37be1aa4
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a22_1.java
@@ -0,0 +1,118 @@
+// fields double initialization
+import java.io.*;
+import java.net.*;
+class Foo {
+ final int k;
+ final int ff = 5;
+ Foo(int i) {
+ k =1;
+ }
+ {
+ k=0;
+ }
+}
+
+class c2 {
+ static final int k;
+ static {
+ k=0;
+ }
+ c2() {
+ int i = k;
+ }
+ static {
+ k =1;
+ }
+}
+
+class c3 {
+ final int k;
+ {
+ k=0;
+ }
+ c3() {
+ int i = k;
+ }
+ {
+ k =1;
+ }
+}
+
+class c4 {
+ final int k;
+ {
+ k=0;
+ }
+ c4(int i) {
+ if (false)
+ k =1;
+ }
+ c4() {
+ this(0);
+ k =1;
+ }
+}
+// redirected ctrs
+class c5 {
+ final int k;
+ c5(int i) {
+ k =1;
+ }
+ c5() {
+ this(0);
+ k =1;
+ }
+
+
+ c5(char c) {
+ }
+ c5(int i, int j) {
+ this('c');
+ k = 5;
+ }
+ c5(String s) {
+ this(0,0);
+ k =1;
+ }
+}
+
+class c6 {
+ final int i;
+ c6() {
+ this(0);
+ }
+ c6(int i) {
+ this(0,0);
+ }
+ c6(int k, int l) {
+ i = k;
+ }
+}
+
+
+
+// multiple initalizers
+class c7 {
+ private final String x;
+ {
+ x = "Hello";
+ }
+
+ private final String y;
+ {
+ y = x;
+ }
+
+ private static int i;
+ {
+ int j = 0;
+ }
+
+ static {
+ i = 9;
+ }
+
+ {
+ y = ""+i;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a24.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a24.java
new file mode 100644
index 000000000000..721be46f5005
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a24.java
@@ -0,0 +1,178 @@
+// unhandled exceptions from superclases/etc
+import java.io.*;
+import java.net.*;
+public class a {
+ a(int i) {}
+}
+
+// super ctr
+
+class b extends a {
+}
+
+class c extends a {
+ c() {
+ }
+
+ c(String s) {
+ this(1);
+ }
+ c(int i) {
+ super(i);
+ }
+}
+
+class A {
+ private A() {}
+ class B extends A {}
+}
+
+class A1 {
+ A1() throws Exception {}
+}
+
+class B1 extends A1
+{}
+
+class A2 extends A1 {
+ A2() {}
+}
+
+
+// exception thrown from within anonymous
+class A3 {
+ void f() throws Exception {
+ new A3() {
+ int g() throws Exception {
+ return 0;
+ }
+ int k=g();
+ };
+ }
+}
+
+
+// in initializer
+class Test{
+ final String s = makeString();
+ String makeString() throws Exception {throw new Exception();}
+}
+
+
+class C1 {
+ public C1() throws IllegalArgumentException {}
+}
+class C2 extends C1 {
+ public C2() {
+ }
+}
+
+// private but accessible base ctr
+class D1 {
+ private D1() {}
+ static class D2 extends D1 {
+ D2() {
+ System.out.println("!");
+ }
+ }
+
+ public static void main(String[] args) {
+ new D2();
+ new D1();
+ }
+}
+
+
+///////////////
+class MyClass
+{
+ public MyClass() throws Exception
+ {
+ //default ctor throws exc
+ }
+
+ public MyClass(Object anObject)
+ {
+ //other ctor does not
+ }
+}
+
+class MyClass2 extends MyClass
+{
+ //HERE good code is marked red
+ public MyClass2 (Object anObject)
+ {
+ super(anObject);
+ }
+}
+
+class ThrowCC {
+ public void test3() throws Exception {
+ Throwable exception = null;
+ throw exception;
+ }
+}
+
+
+//Inaccessible field
+class J {
+ int t = new I1().i; //access object class is OK
+ int v = new I2().i; //bad access object class
+
+ class I1 {
+ class I3 {
+ int t = i; //visibility OK
+ }
+
+ private int i;
+ }
+
+ class I2 extends I1 {
+ int j = i; //We don't see i from baser class
+ }
+
+ static I1 i1;
+ class I4 {
+ int u = i1.i; //OK, i is visible since the toplevel class is the same
+ }
+}
+class Test3 {
+
+ private class Child extends Parent {
+ }
+
+ private class Parent extends SuperParent {
+ }
+
+ private class SuperParent {
+ private int field = 1;
+ }
+
+ public void foo() {
+ Child child = new Child();
+ int i = child.field;
+ }
+}
+
+//IDEADEV-4455: this code is OK
+class XYZ {
+ private class Inner extends XYZ {
+ private final String s;
+ Inner(String _s) {
+ this.s = _s;
+ }
+
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Inner y = (Inner) o;
+
+ if (s != null ? !s.equals(y.s) : y.s != null) return false;
+
+ return true;
+ }
+ }
+}
+//end of IDEADEV-4455
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a25.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a25.java
new file mode 100644
index 000000000000..e2f6b4435919
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a25.java
@@ -0,0 +1,46 @@
+/// assignment compatible types
+import java.io.*;
+import java.net.*;
+public class a {
+ final int FI = 2;
+ final int FIBIG = 200000000;
+
+
+ void f() {
+ // not marked: OK, as literal value is in byte-range
+ byte b1 = 1;
+
+ // marked: OK, as literal value is out of byte-range and does not compile
+ byte b2 = 1000;
+
+ // marked: OK, as char-value cannot be determined and does not compile
+ char c = 0;
+ byte b3 = c;
+
+ // marked: OK, as literal char-value is out of byte-range and does not compile
+ byte b4 = '\u20AC';
+
+ byte b5 = '\n' - 4 + 1800;
+ // literal char-value is in byte-range and compiles fine
+ byte b6 = '\u007F';
+ byte b7=(short) 0;
+ byte b8 = (long)0;
+
+ float f1 = 77.3;
+ float f2 = 77.3F;
+
+ short s1 = 1 + FI;
+ short s2 = 1000000;
+ short s3 = 'F' % FIBIG;
+
+ char c1 = 0;
+ char c2 = -1 + FIBIG;
+ char c3=(byte) 0;
+ char c4=(short) 0;
+ char c5 = 0L;
+
+ int i1='d';
+ int i2 = 1L;
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a28.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a28.java
new file mode 100644
index 000000000000..f4630d248617
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a28.java
@@ -0,0 +1,42 @@
+/// labels
+import java.io.*;
+import java.net.*;
+
+public class a {
+
+ void f(final boolean b) {
+ while (b) break lab1;
+ while (b) continue lab1;
+
+ for (;;) {
+ lab2: ;
+ break lab2;
+ continue lab2;
+ }
+
+ lab3:
+ new Runnable() {
+ public void run() {
+ while (true) {
+ if (b) break lab3;
+ if (b) continue lab3;
+ }
+ }
+ };
+ }
+
+ void cf() {
+ boolean b = false;
+ while (b) {
+ lab0: break lab0;
+ }
+
+ lab1: try {
+ lab2: for (;b;) if (1==3) continue lab2;
+ break lab1;
+ }
+ finally {
+ break lab1;
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a30.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a30.java
new file mode 100644
index 000000000000..88dd9534444e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a30.java
@@ -0,0 +1,74 @@
+/// forward references
+import java.io.*;
+import java.net.*;
+
+public class a {
+
+ {
+ int i;
+ if (FI == 4) i = 5;
+ }
+ final int FI = 4;
+
+ int k = 1 + ki;
+ int ki;
+
+ final int fi5 = fi5 + 1;
+}
+
+class a1 {
+ static int i = j + 2;
+ static int j = 4;
+}
+class a2 {
+ static { i = j + 2; }
+ static int i, j;
+ static { j = 4; }
+}
+
+// pasted from JLS 8.3.2.3
+class UseBeforeDeclaration {
+ static {
+ x = 100; // ok - assignment
+ int y = x + 1; // error - read before declaration
+ int v = x = 3; // ok - x at left hand side of assignment
+ int z = UseBeforeDeclaration.x * 2; // ok - not accessed via simple name
+ Object o = new Object(){
+ void foo(){x++;} // ok - occurs in a different class
+ {x++;} // ok - occurs in a different class
+ };
+ }
+ {
+ j = 200; // ok - assignment
+ j = j + 1; // error - right hand side reads before declaration
+ int k = j = j + 1;
+ int n = j = 300; // ok - j at left hand side of assignment
+ int h = j++; // error - read before declaration
+ int l = this.j * 3; // ok - not accessed via simple name
+ Object o = new Object(){
+ void foo(){j++;} // ok - occurs in a different class
+ { j = j + 1;} // ok - occurs in a different class
+ };
+ }
+
+ int w = x= 3; // ok - x at left hand side of assignment
+ int p = x; // ok - instance initializers may access static fields
+ static int u = (new Object(){int bar(){return x;}}).bar(); // ok - occurs in a different class
+ static int x;
+ int m = j = 4; // ok - j at left hand side of assignment
+ int o = (new Object(){int bar(){return j;}}).bar(); // ok - occurs in a different class
+ int j;
+}
+
+class a3 {
+ static {
+ i+=1;
+ }
+ static int j=i+=1;
+ static int i=0;
+ {
+ k+=1;
+ }
+ int n=k+=1;
+ int k=0;
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a32.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a32.java
new file mode 100644
index 000000000000..141b59274c19
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a32.java
@@ -0,0 +1,40 @@
+// cyclic inhertiance
+import java.io.*;
+import java.net.*;
+
+class Foo extends Foo {
+}
+
+
+interface Foo1 extends Bar {
+ interface Bar {
+ }
+}
+
+
+class c1 extends c2 {}
+class c2 extends c1 {}
+
+
+
+class a1 {
+ class b extends a1 {
+ }
+}
+
+
+class a {
+ static class sb extends a {
+ class c extends a {
+ void f() {
+ class d extends a {
+ }
+ }
+ }
+ }
+ class b extends sb {
+ class c extends a {
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a34.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a34.java
new file mode 100644
index 000000000000..b98824c3da0f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a34.java
@@ -0,0 +1,69 @@
+// labels
+import java.io.*;
+import java.net.*;
+
+class a {
+ void f() {
+ a:
+ }
+ void f1() {
+ a:
+ b:
+ }
+ void f2() {
+ a: return;
+ }
+ void f3() {
+ a: return;
+ }
+ void f4() {
+ a:
+ b:
+ return;
+ }
+ void f5() {
+ a:
+ if (4==5) return;
+ b: ;
+ }
+ void f6() {
+ a: ;
+ }
+}
+
+
+class AlreadyInUse {
+ void f0() {
+ a: {
+ f0();
+ a: f0();
+ }
+
+ }
+ void f1() {
+ a:
+ try {
+ f1();
+ a:
+ f1();
+ }
+ finally {
+ }
+ }
+ void f2() {
+ {
+ a:;
+ }
+ {
+ a:;
+ }
+ }
+ void f3() {
+ a:
+ new Object() {
+ void f() {
+ a:;
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35.java
new file mode 100644
index 000000000000..9060718619b7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35.java
@@ -0,0 +1,8 @@
+// unclosed comment
+/*
+
+import java.io.*;
+import java.net.*;
+
+class a {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_1.java
new file mode 100644
index 000000000000..24870ee08896
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_1.java
@@ -0,0 +1,9 @@
+// unclosed comment
+
+
+import java.io.*;
+import java.net.*;
+
+/**
+class a {
+ int i;
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_2.java
new file mode 100644
index 000000000000..92d457bb059b
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a35_2.java
@@ -0,0 +1,3 @@
+// unclosed decl
+
+class a {
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a37.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a37.java
new file mode 100644
index 000000000000..c34b5e9eec3d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a37.java
@@ -0,0 +1,31 @@
+// ternary operator
+
+class a {
+ void f1() {
+ byte b = 4;
+ int i = 2;
+ boolean bo = false;
+ long l = 5;
+ float f = 5;
+ double d = 45;
+
+ String s;
+ s = bo ? 1 : 2;
+ s = bo ? 1L: 2;
+ s = bo ? b : 2;
+ s = bo ? b : b+2;
+ s = bo ? b+1L : 2;
+ s = bo ? f : f+2;
+ s = bo ? d : 2;
+
+ }
+
+ void cf1() {
+
+ byte[] byteArr = new byte[10];
+ boolean bool = true;
+ byte i = bool ? byteArr[0] : 0;
+ }
+
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a38.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a38.java
new file mode 100644
index 000000000000..64f476698649
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a38.java
@@ -0,0 +1,12 @@
+// duplicates in extends
+
+class a {
+}
+
+class b extends a, a {
+}
+
+interface i {}
+
+class c implements i, i {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a39.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a39.java
new file mode 100644
index 000000000000..74e0fb4456f1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a39.java
@@ -0,0 +1,32 @@
+// exception java.lang.Exception has already been caught/ illegal catch type
+
+import java.io.EOFException;
+import java.io.IOException;
+class Foo {
+ void f() {
+ try {
+ } catch (Throwable t) {
+ } catch (Exception e) {
+ }
+ try {
+ } catch (RuntimeException e) {
+ } catch (NullPointerException e) {
+ }
+ try {
+ throw new EOFException();
+ } catch (IOException e) {
+ } catch (EOFException e) {
+ }
+
+ try {
+ }
+ catch (Exception e) {
+ }
+ catch (Exception e) {
+
+ }
+ }
+
+
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a44.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a44.java
new file mode 100644
index 000000000000..5c725d5ba3dc
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a44.java
@@ -0,0 +1,54 @@
+// constant expressions in switch
+
+import java.util.Date;
+
+class a {
+ final int f = -3;
+
+ void f1() {
+ switch (0) {
+ case new Integer(0).MAX_VALUE:
+ }
+ int k=0;
+ switch (0) {
+ case false ? k : 0:
+ case true ? 1 : k:
+ }
+ boolean b=true;
+ switch (0) {
+ case false && b ? 0 : 1:
+ case true || b ? 2 : 0:
+ }
+ final Object obj="";
+ switch (0) {
+ case obj=="" ? 0 : 0:
+ case this.f:
+ }
+
+ int i = 0;
+ final Integer I = null;
+ switch (0) {
+ case i:
+ case I.MAX_VALUE:
+ case Integer.MAX_VALUE:
+ }
+
+ }
+
+ static class b {
+ static final int c = 8;
+ }
+ void cf1() {
+ final int i = 9;
+ switch (0) {
+ case i:
+ case 2+4:
+ case f:
+ case a.b.c:
+ }
+ switch (0) {
+ case true ^ true ? 0 : 0:
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a45.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a45.java
new file mode 100644
index 000000000000..2ab5a6639eb9
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a45.java
@@ -0,0 +1,55 @@
+// access problems in inner classes
+
+import java.awt.*;
+import java.beans.beancontext.BeanContextServicesSupport;
+import java.beans.beancontext.BeanContextServicesSupport.BCSSChild;
+
+class a extends Component {
+ void f() {
+ FlipBufferStrategy s = null;
+ int i = s.numBuffers;
+ s.createBuffers(1,null);
+
+ // TODO
+ // now cannot distinquish private from package local in class files
+ //< error descr="'java.awt.Component.SingleBufferStrategy' has private access in 'java.awt.Component'">SingleBufferStrategy< /error> s2 = null;
+ //Object o = s2.< error descr="'caps' has private access in 'java.awt.Component.SingleBufferStrategy'">caps< /error>;
+ }
+
+
+
+ class ddd extends BeanContextServicesSupport {
+ BCSSChild.BCSSCServiceClassRef fd = null;
+ void ff() {
+ fd.addRequestor(null,null);
+ }
+ }
+
+}
+
+
+interface I {
+ abstract class Imple implements I {
+ abstract void f();
+ }
+ abstract class Impl2 extends Imple {
+ abstract class Inner extends Impl2 {
+
+ }
+ }
+}
+
+
+class Class1 extends Class2 {
+ public void test() {
+ new Class2Inner();
+ int i = Class2Inner.i;
+ }
+}
+class Class2 {
+ private static class Class2Inner{
+ public static int i;
+ public Class2Inner() {
+ }
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a47.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a47.java
new file mode 100644
index 000000000000..a768aacd9f37
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a47.java
@@ -0,0 +1,35 @@
+// switch statement
+
+class a {
+ {
+ case 0:
+ }
+ {
+ default:
+ }
+
+ {
+ switch (0) {
+ case 0;
+ }
+
+ switch (0) {
+ default;
+ }
+
+ switch (0) {
+ ////////////////
+ /**
+ */
+ System.out.println();
+
+
+ default;
+ }
+
+ switch (0) {
+ break;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a48.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a48.java
new file mode 100644
index 000000000000..df5a2ec2923f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a48.java
@@ -0,0 +1,12 @@
+// assert statement
+
+class a {
+ void f() {
+ assert false : System.out.println();
+
+ assert 0;
+ assert 'a';
+ assert "";
+ assert f();
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a49.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a49.java
new file mode 100644
index 000000000000..6f7edfbead12
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a49.java
@@ -0,0 +1,20 @@
+// sync statement
+
+class a {
+ void f() {
+
+ synchronized (null) {
+ }
+ synchronized (0) {
+ }
+ synchronized ('a') {
+ }
+ synchronized (true) {
+ }
+ synchronized (System.out.println() ) {
+ }
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a50.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a50.java
new file mode 100644
index 000000000000..666b2ec14aea
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a50.java
@@ -0,0 +1,16 @@
+// multiple extend
+
+import java.io.*;
+
+class c1 {}
+class c2 implements Serializable, Externalizable {
+ public void writeExternal(ObjectOutput out) throws IOException {
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ }
+}
+class a extends c1,c2 {
+
+
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a52.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a52.java
new file mode 100644
index 000000000000..9605da3c96b3
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a52.java
@@ -0,0 +1,37 @@
+// recusrsive ctr call
+
+
+class s {
+ s() {
+ this();
+ }
+
+ s(int i) {
+ this(2);
+ }
+}
+
+class c {
+ c() {
+ this(2);
+ }
+
+ c(int i) {
+ this(1,1);
+ }
+ c(int i, int k) {
+ this(1);
+ }
+}
+
+class cv {
+ cv() {
+ this(1);
+ }
+
+ cv(int i) {
+ this(1,2);
+ }
+
+ cv(int i,int j) {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54.java
new file mode 100644
index 000000000000..7a7c9dfcb94e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54.java
@@ -0,0 +1,11 @@
+// single import conflict
+import java.sql.Date;
+import java.util.Date;
+import java.sql.*;
+import java.util.*;
+// multiple single-type import of the same class is fine
+import java.io.IOException;
+import java.io.IOException;
+
+
+public class c {}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54_1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54_1.java
new file mode 100644
index 000000000000..38147e979fa1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a54_1.java
@@ -0,0 +1,9 @@
+// multiple single-type import of the same class
+
+import java.io.IOException;
+import java.io.IOException;
+
+
+public class c {
+ public IOException m;
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a55.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a55.java
new file mode 100644
index 000000000000..f9e9a9abb77d
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a55.java
@@ -0,0 +1,9 @@
+// Not allowed in interface
+
+
+interface A {
+ A();
+ static {}
+ {}
+}
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a59.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a59.java
new file mode 100644
index 000000000000..ceeea4d323af
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a59.java
@@ -0,0 +1,31 @@
+// access static via instance
+class AClass
+{
+ public int get() {
+ int i = this.fff;
+ return i;
+ }
+ public static AClass getA() {
+ return null;
+ }
+
+ Object gg()
+ {
+ return this.getA();
+ }
+ static int fff;
+
+ protected static class R {
+ static int rr = 0;
+ }
+ public R getR() {
+ return null;
+ }
+}
+
+class anotherclass {
+ int f(AClass d){
+ int i = d.getR().rr;
+ return i;
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a60.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a60.java
new file mode 100644
index 000000000000..cba08cdf3f99
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/a60.java
@@ -0,0 +1,17 @@
+class Y {
+ int size = 4;
+}
+
+class Z extends Y {
+ class I {
+ void foo() {
+ System.out.println("size = " + Y.this.size); // illegal construct
+ }
+ }
+}
+
+class R {
+ public void smu() {
+ System.out.println(Z.super.toString());
+ }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader.java
new file mode 100644
index 000000000000..dbe35eaf91c7
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/aClassLoader.java
@@ -0,0 +1,1731 @@
+/*
+ * @(#)ClassLoader.java 1.162 02/03/19
+ *
+ * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ */
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.Stack;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.jar.Manifest;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.security.AccessController;
+import java.security.AccessControlContext;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
+import java.security.Permissions;
+import java.security.CodeSource;
+import java.security.Policy;
+import sun.misc.URLClassPath;
+import sun.misc.Resource;
+import sun.misc.CompoundEnumeration;
+import sun.misc.ClassFileTransformer;
+//import sun.misc.Launcher;
+import sun.reflect.Reflection;
+import sun.security.action.GetPropertyAction;
+
+/**
+ * A class loader is an object that is responsible for loading
+ * classes. The class ClassLoader is an abstract class.
+ * Given the name of a class, a class loader should attempt to locate
+ * or generate data that constitutes a definition for the class. A
+ * typical strategy is to transform the name into a file
+ * name and then read a "class file" of that name from a file system.
+ *
+ * Every Class object contains a
+ * {@link Class#getClassLoader() reference} to the
+ * ClassLoader that defined it.
+ *
+ * Class objects for array classes are not created by class loaders, but
+ * are created automatically as required by the Java runtime. The class
+ * loader for an array class, as returned by {@link Class#getClassLoader()}
+ * is the same as the class loader for its element type; if the element
+ * type is a primitive type, then the array class has no class loader.
+ *
+ * Applications implement subclasses of ClassLoader in
+ * order to extend the manner in which the Java virtual machine
+ * dynamically loads classes.
+ *
+ * Class loaders may typically be used by security managers to
+ * indicate security domains.
+ *
+ * The ClassLoader class uses a delegation model to
+ * search for classes and resources. Each instance of
+ * ClassLoader has an associated parent class loader.
+ * When called upon to find a class or resource, a
+ * ClassLoader instance will delegate the search for
+ * the class or resource to its parent class loader before
+ * attempting to find the class or resource itself. The virtual
+ * machine's built-in class loader, called the bootstrap class loader,
+ * does not itself have a parent but may serve as the parent of a
+ * ClassLoader instance.
+ *
+ * Normally, the Java virtual machine loads classes from the local
+ * file system in a platform-dependent manner. For example, on UNIX
+ * systems, the virtual machine loads classes from the directory
+ * defined by the CLASSPATH environment variable.
+ *
+ * However, some classes may not originate from a file; they may
+ * originate from other sources, such as the network, or they could
+ * be constructed by an application. The method
+ * defineClass converts an array of bytes into an
+ * instance of class Class. Instances of this newly
+ * defined class can be created using the newInstance
+ * method in class Class.
+ *
+ * The methods and constructors of objects created by a class loader
+ * may reference other classes. To determine the class(es) referred
+ * to, the Java virtual machine calls the loadClass
+ * method of the class loader that originally created the class.
+ *
+ * For example, an application could create a network class loader
+ * to download class files from a server. Sample code might look like:
+ *
+ * The network class loader subclass must define the methods
+ * findClass and loadClassData
+ * to load a class from the network. Once it
+ * has downloaded the bytes that make up the class, it should use the
+ * method defineClass to create a class instance. A
+ * sample implementation is:
+ *
+ * class NetworkClassLoader extends ClassLoader {
+ * String host;
+ * int port;
+ *
+ * public Class findClass(String name) {
+ * byte[] b = loadClassData(name);
+ * return defineClass(name, b, 0, b.length);
+ * }
+ *
+ * private byte[] loadClassData(String name) {
+ * // load the class data from the connection
+ * . . .
+ * }
+ * }
+ *
+ *
+ * @version 1.162, 03/19/02
+ * @see java.lang.Class
+ * @see java.lang.Class#newInstance()
+ * @see java.lang.ClassLoader#defineClass(byte[], int, int)
+ * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
+ * @see java.lang.ClassLoader#resolveClass(java.lang.Class)
+ * @since JDK1.0
+ */
+public abstract class ClassLoader {
+
+ private static native void registerNatives();
+ static {
+ registerNatives();
+ }
+
+ /*
+ * If initialization succeed this is set to true and security checks will
+ * succeed. Otherwise the object is not initialized and the object is
+ * useless.
+ */
+ private boolean initialized = false;
+
+ /*
+ * The parent class loader for delegation.
+ */
+ private ClassLoader parent;
+
+ /*
+ * Hashtable that maps packages to certs
+ */
+ private Hashtable package2certs = new Hashtable(11);
+
+ /*
+ * shared among all packages with unsigned classes
+ */
+ java.security.cert.Certificate[] nocerts;
+
+ /*
+ * The classes loaded by this class loader. The only purpose of this
+ * table is to keep the classes from being GC'ed until the loader
+ * is GC'ed.
+ */
+ private Vector classes = new Vector();
+
+ /*
+ * The initiating protection domains for all classes
+ * loaded by this loader.
+ */
+ private Set domains = new HashSet();
+
+ /*
+ * Called by the VM to record every loaded class with this loader.
+ */
+ void addClass(Class c) {
+ classes.addElement(c);
+ }
+
+ /*
+ * The packages defined in this class loader. Each package name is
+ * mapped to its corresponding Package object.
+ */
+ private HashMap packages = new HashMap();
+
+ /**
+ * Creates a new class loader using the specified parent class loader
+ * for delegation.
+ *
+ * If there is a security manager, its checkCreateClassLoader
+ * method is called. This may result in a security exception.
+ *
+ * @param parent the parent class loader
+ *
+ * @throws SecurityException if a security manager exists and its
+ * checkCreateClassLoader method doesn't allow creation of a
+ * new class loader.
+ * @see java.lang.SecurityException
+ * @see java.lang.SecurityManager#checkCreateClassLoader()
+ * @since 1.2
+ */
+ protected ClassLoader(ClassLoader parent) {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkCreateClassLoader();
+ }
+ this.parent = parent;
+ initialized = true;
+ }
+
+ /**
+ * Creates a new class loader using the ClassLoader
+ * returned by the method getSystemClassLoader() as the
+ * parent class loader.
+ *
+ * If there is a security manager, its checkCreateClassLoader
+ * method is called. This may result in a security exception.
+ *
+ * @throws SecurityException
+ * if a security manager exists and its checkCreateClassLoader
+ * method doesn't allow creation of a new class loader.
+ *
+ * @see java.lang.SecurityException
+ * @see java.lang.SecurityManager#checkCreateClassLoader()
+ */
+ protected ClassLoader() {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkCreateClassLoader();
+ }
+ this.parent = getSystemClassLoader();
+ initialized = true;
+ }
+
+ /**
+ * Loads the class with the specified name. This method searches for
+ * classes in the same manner as the {@link #loadClass(String, boolean)}
+ * method. It is called by the Java virtual machine to resolve class
+ * references. Calling this method is equivalent to calling
+ * loadClass(name, false).
+ *
+ * @param name the name of the class
+ * @return the resulting Class object
+ * @exception ClassNotFoundException if the class was not found
+ */
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ return loadClass(name, false);
+ }
+
+ /**
+ * Loads the class with the specified name. The default implementation of
+ * this method searches for classes in the following order:
+ *
+ *
+ *
Call {@link #findLoadedClass(String)} to check if the class has
+ * already been loaded.
+ *
Call the loadClass method on the parent class
+ * loader. If the parent is null the class loader
+ * built-in to the virtual machine is used, instead.
+ *
Call the {@link #findClass(String)} method to find the class.
+ *
+ *
+ * If the class was found using the above steps, and the
+ * resolve flag is true, this method will then call the
+ * {@link #resolveClass(Class)} method on the resulting class object.
+ *
+ * From the Java 2 SDK, v1.2, subclasses of ClassLoader are
+ * encouraged to override
+ * {@link #findClass(String)}, rather than this method.
+ *
+ * @param name the name of the class
+ * @param resolve if true then resolve the class
+ * @return the resulting Class object
+ * @exception ClassNotFoundException if the class could not be found
+ */
+ protected synchronized Class loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ // First, check if the class has already been loaded
+ Class c = findLoadedClass(name);
+ if (c == null) {
+ try {
+ if (parent != null) {
+ c = parent.loadClass(name, false);
+ } else {
+ c = findBootstrapClass0(name);
+ }
+ } catch (ClassNotFoundException e) {
+ // If still not found, then call findClass in order
+ // to find the class.
+ c = findClass(name);
+ }
+ }
+ if (resolve) {
+ resolveClass(c);
+ }
+ return c;
+ }
+
+ /*
+ * This method is called by the virtual machine to load
+ * a class.
+ */
+ private synchronized Class loadClassInternal(String name)
+ throws ClassNotFoundException {
+
+ return loadClass(name);
+ }
+
+ private void checkPackageAccess(Class cls, ProtectionDomain pd) {
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ final String name = cls.getName();
+ final int i = name.lastIndexOf('.');
+ if (i != -1) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ sm.checkPackageAccess(name.substring(0, i));
+ return null;
+ }
+ }, new AccessControlContext(new ProtectionDomain[] {pd}));
+ }
+ }
+ domains.add(pd);
+ }
+
+ /**
+ * Finds the specified class. This method should be overridden
+ * by class loader implementations that follow the new delegation model
+ * for loading classes, and will be called by the loadClass
+ * method after checking the parent class loader for the requested class.
+ * The default implementation throws ClassNotFoundException.
+ *
+ * @param name the name of the class
+ * @return the resulting Class object
+ * @exception ClassNotFoundException if the class could not be found
+ * @since 1.2
+ */
+ protected Class findClass(String name) throws ClassNotFoundException {
+ throw new ClassNotFoundException(name);
+ }
+
+ /**
+ * Converts an array of bytes into an instance of class
+ * Class. Before the Class can be used it must be
+ * resolved. This method is deprecated in favor of the version
+ * that takes the class name as its first argument, and is more
+ * secure.
+ *
+ * @param b the bytes that make up the class data. The bytes in
+ * positions off through off+len-1
+ * should have the format of a valid class file as defined
+ * by the
+ * Java
+ * Virtual Machine Specification.
+ * @param off the start offset in b of the class data
+ * @param len the length of the class data
+ * @return the Class object that was created from the
+ * specified class data
+ * @exception ClassFormatError if the data did not contain a valid class
+ * @exception IndexOutOfBoundsException if either off or
+ * len is negative, or if
+ * off+len is greater than b.length.
+ * @see ClassLoader#loadClass(java.lang.String, boolean)
+ * @see ClassLoader#resolveClass(java.lang.Class)
+ * @deprecated Replaced by defineClass(java.lang.String, byte[], int, int)
+ */
+ protected final Class defineClass(byte[] b, int off, int len)
+ throws ClassFormatError
+ {
+ return defineClass(null, b, off, len, null);
+ }
+
+ /**
+ * Converts an array of bytes into an instance of class Class.
+ * Before the Class can be used it must be resolved.
+ *
+ * This method assigns a default ProtectionDomain to
+ * the newly defined class. The ProtectionDomain
+ * contains the set of permissions granted when
+ * a call to Policy.getPolicy().getPermissions() is made with
+ * a code source of null,null. The default domain is
+ * created on the first invocation of defineClass, and
+ * re-used on subsequent calls.
+ *
+ * To assign a specific ProtectionDomain to the class,
+ * use the defineClass method that takes a
+ * ProtectionDomain as one of its arguments.
+ *
+ * @param name the expected name of the class, or null
+ * if not known, using '.' and not '/' as the separator
+ * and without a trailing ".class" suffix.
+ * @param b the bytes that make up the class data. The bytes in
+ * positions off through off+len-1
+ * should have the format of a valid class file as defined
+ * by the
+ * Java
+ * Virtual Machine Specification.
+ * @param off the start offset in b of the class data
+ * @param len the length of the class data
+ * @return the Class object that was created from the
+ * specified class data
+ * @exception ClassFormatError if the data did not contain a valid class
+ * @exception IndexOutOfBoundsException if either off or
+ * len is negative, or if
+ * off+len is greater than b.length.
+ * @exception SecurityException if an attempt is made to add this class
+ * to a package that contains classes that were signed by
+ * a different set of certificates than this class (which
+ * is unsigned), or if the class name begins with "java.".
+ *
+ * @see ClassLoader#loadClass(java.lang.String, boolean)
+ * @see ClassLoader#resolveClass(java.lang.Class)
+ * @see java.security.ProtectionDomain
+ * @see java.security.Policy
+ * @see java.security.CodeSource
+ * @see java.security.SecureClassLoader
+ * @since JDK1.1
+ */
+ protected final Class defineClass(String name, byte[] b, int off, int len)
+ throws ClassFormatError
+ {
+ return defineClass(name, b, off, len, null);
+ }
+
+ /**
+ * Converts an array of bytes into an instance of class Class,
+ * with an optional ProtectionDomain. If the domain is null,
+ * then a default domain will be assigned to the class as specified
+ * in the documentation for {@link #defineClass(String,byte[],int,int)}.
+ * Before the class can be used it must be resolved.
+ *
+ *
The first class defined in a package determines the exact set of
+ * certificates that all subsequent classes defined in that package must
+ * contain. The set of certificates for a class is obtained from the
+ * CodeSource within the ProtectionDomain of
+ * the class. Any classes added to that package must contain
+ * the same set of certificates or a SecurityException
+ * will be thrown. Note that if the name argument is
+ * null, this check is not performed. You should always pass in the
+ * name of the class you are defining as well as the bytes. This
+ * ensures that the class you are defining is indeed the class
+ * you think it is.
+ *
+ *
The specified class name cannot begin with "java.", since all
+ * classes in the java.* packages can only be defined by the bootstrap
+ * class loader. If the name parameter is not null, it
+ * must be equal to the name of the class specified by the byte
+ * array b, otherwise a ClassFormatError is raised.
+ *
+ * @param name the expected name of the class, or null
+ * if not known, using '.' and not '/' as the separator
+ * and without a trailing ".class" suffix.
+ * @param b the bytes that make up the class data. The bytes in
+ * positions off through off+len-1
+ * should have the format of a valid class file as defined
+ * by the
+ * Java
+ * Virtual Machine Specification.
+ * @param off the start offset in b of the class data
+ * @param len the length of the class data
+ * @param protectionDomain the ProtectionDomain of the class
+ * @return the Class object created from the data,
+ * and optional ProtectionDomain.
+ * @exception ClassFormatError if the data did not contain a valid class
+ * @exception IndexOutOfBoundsException if either off or
+ * len is negative, or if
+ * off+len is greater than b.length.
+ * @exception SecurityException if an attempt is made to add this class
+ * to a package that contains classes that were signed by
+ * a different set of certificates than this class, or if
+ * the class name begins with "java.".
+ */
+ protected final Class defineClass(String name, byte[] b, int off, int len,
+ ProtectionDomain protectionDomain)
+ throws ClassFormatError
+ {
+ check();
+ if ((name != null) && name.startsWith("java.")) {
+ throw new SecurityException("Prohibited package name: " +
+ name.substring(0, name.lastIndexOf('.')));
+ }
+ if (protectionDomain == null) {
+ protectionDomain = getDefaultDomain();
+ }
+
+ if (name != null)
+ checkCerts(name, protectionDomain.getCodeSource());
+
+ Class c = null;
+
+ try
+ {
+ c = defineClass0(name, b, off, len, protectionDomain);
+ }
+ catch (ClassFormatError cfe)
+ {
+ // Class format error - try to transform the bytecode and
+ // define the class again
+ //
+ Object[] transformers = ClassFileTransformer.getTransformers();
+
+ for (int i=0; transformers != null && i < transformers.length; i++)
+ {
+ try
+ {
+ // Transform byte code using transformer
+ byte[] tb = ((ClassFileTransformer) transformers[i]).transform(b, off, len);
+ c = defineClass0(name, tb, 0, tb.length, protectionDomain);
+ break;
+ }
+ catch (ClassFormatError cfe2)
+ {
+ // If ClassFormatError occurs, try next transformer
+ }
+ }
+
+ // Rethrow original ClassFormatError if unable to transform
+ // bytecode to well-formed
+ //
+ if (c == null)
+ throw cfe;
+ }
+
+ if (protectionDomain.getCodeSource() != null) {
+ java.security.cert.Certificate certs[] =
+ protectionDomain.getCodeSource().getCertificates();
+ if (certs != null)
+ setSigners(c, certs);
+ }
+ return c;
+ }
+
+ private synchronized void checkCerts(String name, CodeSource cs)
+ {
+ int i = name.lastIndexOf('.');
+ String pname = (i == -1) ? "" : name.substring(0,i);
+ java.security.cert.Certificate[] pcerts =
+ (java.security.cert.Certificate[]) package2certs.get(pname);
+ if (pcerts == null) {
+ // first class in this package gets to define which
+ // certificates must be the same for all other classes
+ // in this package
+ if (cs != null) {
+ pcerts = cs.getCertificates();
+ }
+ if (pcerts == null) {
+ if (nocerts == null)
+ nocerts = new java.security.cert.Certificate[0];
+ pcerts = nocerts;
+ }
+ package2certs.put(pname, pcerts);
+ } else {
+ java.security.cert.Certificate[] certs = null;
+ if (cs != null) {
+ certs = cs.getCertificates();
+ }
+
+ if (!compareCerts(pcerts,certs)) {
+ throw new SecurityException("class \""+ name+
+ "\"'s signer information does not match signer information of other classes in the same package");
+ }
+ }
+ }
+
+ /**
+ * check to make sure the certs for the new class (certs) are
+ * the same as the certs for the first class inserted
+ * in the package (pcerts)
+ */
+ private boolean compareCerts(java.security.cert.Certificate[] pcerts,
+ java.security.cert.Certificate[] certs)
+ {
+ // certs can be null, indicating no certs.
+ if ((certs == null) || (certs.length == 0)) {
+ return pcerts.length == 0;
+ }
+
+ // the length must be the same at this point
+ if (certs.length != pcerts.length)
+ return false;
+
+ // go through and make sure all the certs in one array
+ // are in the other and vice-versa.
+ boolean match;
+ for (int i=0; i < certs.length; i++) {
+ match = false;
+ for (int j=0; j < pcerts.length; j++) {
+ if (certs[i].equals(pcerts[j])) {
+ match = true;
+ break;
+ }
+ }
+ if (!match) return false;
+ }
+
+ // now do the same for pcerts
+ for (int i=0; i < pcerts.length; i++) {
+ match = false;
+ for (int j=0; j < certs.length; j++) {
+ if (pcerts[i].equals(certs[j])) {
+ match = true;
+ break;
+ }
+ }
+ if (!match) return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Links the specified class.
+ * This (misleadingly named) method may be used by a class loader to
+ * link a class. If the class c has already been linked,
+ * then this method simply returns. Otherwise, the class is linked
+ * as described in the "Execution" chapter of the Java Language
+ * Specification.
+ *
+ * @param c the class to link
+ * @exception NullPointerException if c is null.
+ * @see java.lang.ClassLoader#defineClass(java.lang.String,byte[],int,int)
+ */
+ protected final void resolveClass(Class c) {
+ check();
+ resolveClass0(c);
+ }
+
+ /**
+ * Finds a class with the specified name, loading it if necessary.
+ *
+ * Prior to the Java 2 SDK, this method loads a class from the local file
+ * system in a platform-dependent manner, and returns a class object
+ * that has no associated class loader.
+ *
+ * Since the Java 2 SDK v1.2, this method loads the class through the
+ * system class loader(see {@link #getSystemClassLoader()}). Class objects
+ * returned might have ClassLoaders associated with them.
+ * Subclasses of ClassLoader need not usually call this
+ * method, because most class loaders need to override just {@link
+ * #findClass(String)}.
+ *
+ * @param name the name of the class that is to be found
+ * @return the Class object for the specified
+ * name
+ * @exception ClassNotFoundException if the class could not be found
+ * @see #ClassLoader(ClassLoader)
+ * @see #getParent()
+ */
+ protected final Class findSystemClass(String name)
+ throws ClassNotFoundException
+ {
+ check();
+ ClassLoader system = getSystemClassLoader();
+ if (system == null) {
+ return findBootstrapClass(name);
+ }
+ return system.loadClass(name);
+ }
+
+ /**
+ * Returns the parent class loader for delegation. Some implementations
+ * may use null to represent the bootstrap class
+ * loader. This method will return null in such
+ * implementations if this class loader's parent is the bootstrap
+ * class loader.
+ *
+ * If a security manager is present, and the caller's class loader is
+ * not null and is not an ancestor of this class loader, then
+ * this method calls the security manager's checkPermission
+ * method with a RuntimePermission("getClassLoader")
+ * permission to ensure it's ok to access the parent class loader.
+ * If not, a SecurityException will be thrown.
+ *
+ * @return the parent ClassLoader
+ * @throws SecurityException
+ * if a security manager exists and its
+ * checkPermission method doesn't allow
+ * access to this class loader's parent class loader.
+ *
+ * @see SecurityManager#checkPermission
+ * @see java.lang.RuntimePermission
+ *
+ * @since 1.2
+ */
+ public final ClassLoader getParent() {
+ if (parent == null)
+ return null;
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ ClassLoader ccl = getCallerClassLoader();
+ if (ccl != null && !isAncestor(ccl)) {
+ sm.checkPermission(getGetClassLoaderPerm());
+ }
+ }
+ return parent;
+ }
+
+ /**
+ * Sets the signers of a class. This should be called after defining a
+ * class.
+ *
+ * @param c the Class object
+ * @param signers the signers for the class
+ * @since JDK1.1
+ */
+ protected final void setSigners(Class c, Object[] signers) {
+ check();
+ c.setSigners(signers);
+ }
+
+ private Class findBootstrapClass0(String name)
+ throws ClassNotFoundException {
+ check();
+ return findBootstrapClass(name);
+ }
+
+ private native Class defineClass0(String name, byte[] b, int off, int len,
+ ProtectionDomain pd);
+ private native void resolveClass0(Class c);
+ private native Class findBootstrapClass(String name)
+ throws ClassNotFoundException;
+
+ /*
+ * Check to make sure the class loader has been initialized.
+ */
+ private void check() {
+ if (!initialized) {
+ throw new SecurityException("ClassLoader object not initialized");
+ }
+ }
+
+ /**
+ * Finds the class with the given name if it had been previously loaded
+ * through this class loader.
+ *
+ * @param name the class name
+ * @return the Class object, or null if
+ * the class has not been loaded
+ * @since JDK1.1
+ */
+ protected native final Class findLoadedClass(String name);
+
+ /**
+ * Finds the resource with the given name. A resource is some data
+ * (images, audio, text, etc) that can be accessed by class code in a way
+ * that is independent of the location of the code.
+ *
+ * The name of a resource is a "/"-separated path name that identifies
+ * the resource.
+ *
+ * This method will first search the parent class loader for the resource;
+ * if the parent is null the path of the class loader
+ * built-in to the virtual machine is searched. That failing, this method
+ * will call findResource to find the resource.
+ *
+ * @param name resource name
+ * @return a URL for reading the resource, or null if
+ * the resource could not be found or the caller doesn't have
+ * adequate privileges to get the resource.
+ * @since JDK1.1
+ * @see #findResource(String)
+ */
+ public URL getResource(String name) {
+ URL url;
+ if (parent != null) {
+ url = parent.getResource(name);
+ } else {
+ url = getBootstrapResource(name);
+ }
+ if (url == null) {
+ url = findResource(name);
+ }
+ return url;
+ }
+
+ /**
+ * Finds all the resources with the given name. A resource is some data
+ * (images, audio, text, etc) that can be accessed by class code in a way
+ * that is independent of the location of the code.
+ *
+ * The name of a resource is a "/"-separated path name that identifies the
+ * resource.
+ *
+ * The search order is described in the documentation for {@link
+ * #getResource(String)}.
+ *
+ * @param name resource name
+ * @return an enumeration of URL to the resource. If no resources could
+ * be found, the enumeration will be empty. Resources that the
+ * doesn't have access to will not be in the enumeration.
+ * @throws IOException if I/O errors occur
+ * @since 1.2
+ * @see #getResource
+ * @see #findResources
+ */
+ public final Enumeration getResources(String name) throws IOException {
+ Enumeration[] tmp = new Enumeration[2];
+ if (parent != null) {
+ tmp[0] = parent.getResources(name);
+ } else {
+ tmp[0] = getBootstrapResources(name);
+ }
+ tmp[1] = findResources(name);
+
+ return new CompoundEnumeration(tmp);
+ }
+
+ /**
+ * Returns an Enumeration of URLs representing all the resources with
+ * the given name. Class loader implementations should override this
+ * method to specify where to load resources from.
+ *
+ * @param name the resource name
+ * @return an Enumeration of URLs for the resources
+ * @throws IOException if I/O errors occur
+ * @since 1.2
+ */
+ protected Enumeration findResources(String name) throws IOException {
+ return new CompoundEnumeration(new Enumeration[0]);
+ }
+
+ /**
+ * Finds the resource with the given name. Class loader
+ * implementations should override this method to specify where to
+ * find resources.
+ *
+ * @param name the resource name
+ * @return a URL for reading the resource, or null
+ * if the resource could not be found
+ * @since 1.2
+ */
+ protected URL findResource(String name) {
+ return null;
+ }
+
+ /**
+ * Find a resource of the specified name from the search path used to load
+ * classes.
+ *
+ * In JDK1.1, the search path used is that of the virtual machine's
+ * built-in class loader.
+ *
+ * Since the Java 2 SDK v1.2, this method locates the resource through the system class
+ * loader (see {@link #getSystemClassLoader()}).
+ *
+ * @param name the resource name
+ * @return a URL for reading the resource, or null if
+ * the resource could not be found
+ * @since JDK1.1
+ */
+ public static URL getSystemResource(String name) {
+ ClassLoader system = getSystemClassLoader();
+ if (system == null) {
+ return getBootstrapResource(name);
+ }
+ return system.getResource(name);
+ }
+
+ /**
+ * Find resources from the VM's built-in classloader.
+ */
+ private static URL getBootstrapResource(String name) {
+ URLClassPath ucp = getBootstrapClassPath();
+ Resource res = ucp.getResource(name);
+ return res != null ? res.getURL() : null;
+ }
+
+ /**
+ * Finds all resources of the specified name from the search path used to
+ * load classes. The resources thus found are returned as an
+ * Enumeration of URL objects.
+ *
+ * The search order is described in the documentation for {@link
+ * #getSystemResource(String)}.
+ *
+ * @param name the resource name
+ * @return an enumeration of resource URLs
+ * @throws IOException if I/O errors occur
+ * @since 1.2
+ */
+ public static Enumeration getSystemResources(String name)
+ throws IOException
+ {
+ ClassLoader system = getSystemClassLoader();
+ if (system == null) {
+ return getBootstrapResources(name);
+ }
+ return system.getResources(name);
+ }
+
+ /**
+ * Find resources from the VM's built-in classloader.
+ */
+ private static Enumeration getBootstrapResources(String name)
+ throws IOException
+ {
+ final Enumeration e = getBootstrapClassPath().getResources(name);
+ return new Enumeration () {
+ public Object nextElement() {
+ return ((Resource)e.nextElement()).getURL();
+ }
+ public boolean hasMoreElements() {
+ return e.hasMoreElements();
+ }
+ };
+ }
+
+ /*
+ * Returns the URLClassPath that is used for finding system resources.
+ */
+ static URLClassPath getBootstrapClassPath() {
+ if (bootstrapClassPath == null) {
+ bootstrapClassPath = sun.misc.Launcher.getBootstrapClassPath();
+ }
+ return bootstrapClassPath;
+ }
+
+ private static URLClassPath bootstrapClassPath;
+
+ /**
+ * Returns an input stream for reading the specified resource.
+ *
+ * The search order is described in the documentation for {@link
+ * #getResource(String)}.
+ *
+ * @param name the resource name
+ * @return an input stream for reading the resource, or null
+ * if the resource could not be found
+ * @since JDK1.1
+ */
+ public InputStream getResourceAsStream(String name) {
+ URL url = getResource(name);
+ try {
+ return url != null ? url.openStream() : null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Open for reading, a resource of the specified name from the search path
+ * used to load classes.
+ *
+ * The search order is described in the documentation for {@link
+ * #getSystemResource(String)}.
+ *
+ * @param name the resource name
+ * @return an input stream for reading the resource, or null
+ * if the resource could not be found
+ * @since JDK1.1
+ */
+ public static InputStream getSystemResourceAsStream(String name) {
+ URL url = getSystemResource(name);
+ try {
+ return url != null ? url.openStream() : null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the system class loader for delegation. This is the default
+ * delegation parent for new ClassLoader instances, and
+ * is typically the class loader used to start the application.
+ *
+ * This method is first invoked early in the runtime's startup
+ * sequence, at which point it creates the system class loader
+ * and sets it as the context class loader of the invoking
+ * Thread.
+ *
+ * The default system class loader is an implementation-dependent
+ * instance of this class.
+ *
+ * If the system property java.system.class.loader is
+ * defined when this method is first invoked then the value of that
+ * property is taken to be the name of a class that will be returned as
+ * the system class loader. The class is loaded using the default system
+ * class loader and must define a public constructor that takes a single
+ * parameter of type ClassLoader which is used
+ * as the delegation parent. An instance is then created using this
+ * constructor with the default system class loader as the parameter.
+ * The resulting class loader is defined to be the system class loader.
+ *
+ * If a security manager is present, and the caller's class loader is
+ * not null and the caller's class loader is not the same as or an ancestor of
+ * the system class loader, then
+ * this method calls the security manager's checkPermission
+ * method with a RuntimePermission("getClassLoader")
+ * permission to ensure it's ok to access the system class loader.
+ * If not, a SecurityException will be thrown.
+ *
+ * @return the system ClassLoader for delegation, or
+ * null if none
+ * @throws SecurityException
+ * if a security manager exists and its
+ * checkPermission method doesn't allow
+ * access to the system class loader.
+ * @throws IllegalStateException
+ * if invoked recursively during the construction
+ * of the class loader specified by the
+ * java.system.class.loader property.
+ * @throws Error
+ * if the system property java.system.class.loader
+ * is defined but the named class could not be loaded, the
+ * provider class does not define the required constructor, or an
+ * exception is thrown by that constructor when it is invoked. The
+ * underlying cause of the error can be retrieved via the
+ * {@link Throwable#getCause()} method.
+ * @see SecurityManager#checkPermission
+ * @see java.lang.RuntimePermission
+ * @revised 1.4
+ */
+ public static ClassLoader getSystemClassLoader() {
+ initSystemClassLoader();
+ if (scl == null) {
+ return null;
+ }
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ ClassLoader ccl = getCallerClassLoader();
+ if (ccl != null && ccl != scl && !scl.isAncestor(ccl)) {
+ sm.checkPermission(getGetClassLoaderPerm());
+ }
+ }
+ return scl;
+ }
+
+ private static synchronized void initSystemClassLoader() {
+ if (!sclSet) {
+ if (scl != null)
+ throw new IllegalStateException("recursive call");
+ sun.misc.Launcher l = sun.misc.Launcher.getLauncher();
+ if (l != null) {
+ Throwable oops = null;
+ scl = l.getClassLoader();
+ try {
+ PrivilegedExceptionAction a;
+ a = new SystemClassLoaderAction(scl);
+ scl = (ClassLoader) AccessController.doPrivileged(a);
+ } catch (PrivilegedActionException pae) {
+ oops = pae.getCause();
+ if (oops instanceof InvocationTargetException) {
+ oops = oops.getCause();
+ }
+ }
+ if (oops != null) {
+ if (oops instanceof Error) {
+ throw (Error) oops;
+ } else {
+ // wrap the exception
+ throw new Error(oops);
+ }
+ }
+ }
+ sclSet = true;
+ }
+ }
+
+ // Returns true if the specified class loader can be found
+ // in this class loader's delegation chain.
+ boolean isAncestor(ClassLoader cl) {
+ ClassLoader acl = this;
+ do {
+ acl = acl.parent;
+ if (cl == acl) {
+ return true;
+ }
+ } while (acl != null);
+ return false;
+ }
+
+ // Returns the caller's class loader, or null if none.
+ // NOTE this must always be called when there is exactly one
+ // intervening frame from the core libraries on the stack between
+ // this method's invocation and the desired caller.
+ static ClassLoader getCallerClassLoader() {
+ // NOTE use of more generic Reflection.getCallerClass()
+ Class caller = Reflection.getCallerClass(3);
+ // This can be null if the VM is requesting it
+ if (caller == null) {
+ return null;
+ }
+ // Circumvent security check since this is package-private
+ return caller.getClassLoader0();
+ }
+
+ // The class loader for the system
+ private static ClassLoader scl;
+
+ // Set to true once the system class loader has been set
+ private static boolean sclSet;
+
+ // Permission to access system or parent class loader
+ private static RuntimePermission getClassLoaderPerm = null;
+
+ static RuntimePermission getGetClassLoaderPerm()
+ {
+ if (getClassLoaderPerm == null)
+ getClassLoaderPerm = new RuntimePermission("getClassLoader");
+ return getClassLoaderPerm;
+ }
+
+ /**
+ * Defines a package by name in this ClassLoader. This allows class
+ * loaders to define the packages for their classes. Packages must be
+ * created before the class is defined, and package names must be
+ * unique within a class loader and cannot be redefined or changed
+ * once created.
+ *
+ * @param name the package name
+ * @param specTitle the specification title
+ * @param specVersion the specification version
+ * @param specVendor the specification vendor
+ * @param implTitle the implementation title
+ * @param implVersion the implementation version
+ * @param implVendor the implementation vendor
+ * @param sealBase If not null, then this package is sealed with
+ * respect to the given code source URL. Otherwise,
+ * the package is not sealed.
+ * @return the newly defined Package object
+ * @exception IllegalArgumentException if package name duplicates an
+ * existing package either in this class loader or one of
+ * its ancestors
+ * @since 1.2
+ */
+ protected Package definePackage(String name, String specTitle,
+ String specVersion, String specVendor,
+ String implTitle, String implVersion,
+ String implVendor, URL sealBase)
+ throws IllegalArgumentException
+ {
+ synchronized (packages) {
+ Package pkg = getPackage(name);
+ if (pkg != null) {
+ throw new IllegalArgumentException(name);
+ }
+ pkg = new Package(name, specTitle, specVersion, specVendor,
+ implTitle, implVersion, implVendor,
+ sealBase);
+ packages.put(name, pkg);
+ return pkg;
+ }
+ }
+
+ /**
+ * Returns a Package that has been defined by this class loader or any
+ * of its ancestors.
+ *
+ * @param name the package name
+ * @return the Package corresponding to the given name, or null if not
+ * found
+ * @since 1.2
+ */
+ protected Package getPackage(String name) {
+ synchronized (packages) {
+ Package pkg = (Package)packages.get(name);
+ if (pkg == null) {
+ if (parent != null) {
+ pkg = parent.getPackage(name);
+ } else {
+ pkg = Package.getSystemPackage(name);
+ }
+ if (pkg != null) {
+ packages.put(name, pkg);
+ }
+ }
+ return pkg;
+ }
+ }
+
+ /**
+ * Returns all of the Packages defined by this class loader and its
+ * ancestors.
+ *
+ * @return the array of Package objects defined by this
+ * ClassLoader
+ * @since 1.2
+ */
+ protected Package[] getPackages() {
+ Map map;
+ synchronized (packages) {
+ map = (Map)packages.clone();
+ }
+ Package[] pkgs;
+ if (parent != null) {
+ pkgs = parent.getPackages();
+ } else {
+ pkgs = Package.getSystemPackages();
+ }
+ if (pkgs != null) {
+ for (int i = 0; i < pkgs.length; i++) {
+ String pkgName = pkgs[i].getName();
+ if (map.get(pkgName) == null) {
+ map.put(pkgName, pkgs[i]);
+ }
+ }
+ }
+ return (Package[])map.values().toArray(new Package[map.size()]);
+ }
+
+ /**
+ * Returns the absolute path name of a native library. The VM
+ * invokes this method to locate the native libraries that belong
+ * to classes loaded with this class loader. If this method returns
+ * null, the VM searches the library along the path
+ * specified as the java.library.path property.
+ *
+ * @param libname the library name
+ * @return the absolute path of the native library
+ * @see java.lang.System#loadLibrary(java.lang.String)
+ * @see java.lang.System#mapLibraryName(java.lang.String)
+ * @since 1.2
+ */
+ protected String findLibrary(String libname) {
+ return null;
+ }
+
+ /**
+ * The inner class NativeLibrary denotes a loaded native library
+ * instance. Every classloader contains a vector of loaded native
+ * libraries in the private field nativeLibraries.
+ * The native libraries loaded into the system are entered into
+ * the systemNativeLibraries vector.
+ *
+ * Every native library reuqires a particular version of JNI. This
+ * is denoted by the private jniVersion field. This field is set
+ * by the VM when it loads the library, and used by the VM to pass
+ * the correct version of JNI to the native methods.
+ *
+ * @version 1.162, 03/19/02
+ * @see java.lang.ClassLoader
+ * @since 1.2
+ */
+ static class NativeLibrary {
+ /* opaque handle to native library, used in native code. */
+ long handle;
+ /* the version of JNI environment the native library requires. */
+ private int jniVersion;
+ /* the class from which the library is loaded, also indicates
+ the loader this native library belongs. */
+ private Class fromClass;
+ /* the canonicalized name of the native library. */
+ String name;
+
+ native void load(String name);
+ native long find(String name);
+ native void unload();
+
+ public NativeLibrary(Class fromClass, String name) {
+ this.name = name;
+ this.fromClass = fromClass;
+ }
+
+ protected void finalize() {
+ synchronized (loadedLibraryNames) {
+ if (fromClass.getClassLoader() != null && handle != 0) {
+ /* remove the native library name */
+ int size = loadedLibraryNames.size();
+ for (int i = 0; i < size; i++) {
+ if (name.equals(loadedLibraryNames.elementAt(i))) {
+ loadedLibraryNames.removeElementAt(i);
+ break;
+ }
+ }
+ /* unload the library. */
+ ClassLoader.nativeLibraryContext.push(this);
+ try {
+ unload();
+ } finally {
+ ClassLoader.nativeLibraryContext.pop();
+ }
+ }
+ }
+ }
+ /* Called in the VM to determine the context class in
+ JNI_Load/JNI_Unload */
+ static Class getFromClass() {
+ return ((NativeLibrary)
+ (ClassLoader.nativeLibraryContext.peek())).fromClass;
+ }
+ }
+
+ /* the "default" domain. Set as the default ProtectionDomain
+ * on newly created classses.
+ */
+ private ProtectionDomain defaultDomain = null;
+
+ /*
+ * returns (and initializes) the default domain.
+ */
+
+ private synchronized ProtectionDomain getDefaultDomain() {
+ if (defaultDomain == null) {
+ CodeSource cs = new CodeSource(null, null);
+ defaultDomain = new ProtectionDomain(cs, null, this, null);
+ }
+ return defaultDomain;
+ }
+
+ /* All native library names we've loaded. */
+ private static Vector loadedLibraryNames = new Vector();
+ /* Native libraries belonging to system classes. */
+ private static Vector systemNativeLibraries = new Vector();
+ /* Native libraries associated with the class loader. */
+ private Vector nativeLibraries = new Vector();
+
+ /* native libraries being loaded/unloaded. */
+ private static Stack nativeLibraryContext = new Stack();
+
+ /* The paths searched for libraries */
+ static private String usr_paths[];
+ static private String sys_paths[];
+
+ private static String[] initializePath(String propname) {
+ String ldpath = System.getProperty(propname, "");
+ String ps = File.pathSeparator;
+ int ldlen = ldpath.length();
+ int i, j, n;
+ // Count the separators in the path
+ i = ldpath.indexOf(ps);
+ n = 0;
+ while (i >= 0) {
+ n++;
+ i = ldpath.indexOf(ps, i+1);
+ }
+
+ // allocate the array of paths - n :'s = n + 1 path elements
+ String[] paths = new String[n + 1];
+
+ // Fill the array with paths from the ldpath
+ n = i = 0;
+ j = ldpath.indexOf(ps);
+ while (j >= 0) {
+ if (j - i > 0) {
+ paths[n++] = ldpath.substring(i, j);
+ } else if (j - i == 0) {
+ paths[n++] = ".";
+ }
+ i = j + 1;
+ j = ldpath.indexOf(ps, i);
+ }
+ paths[n] = ldpath.substring(i, ldlen);
+ return paths;
+ }
+
+
+ /* Called in the java.lang.Runtime class to implement load
+ * and loadLibrary.
+ */
+ static void loadLibrary(Class fromClass, String name,
+ boolean isAbsolute) {
+ ClassLoader loader =
+ (fromClass == null) ? null : fromClass.getClassLoader();
+ if (sys_paths == null) {
+ usr_paths = initializePath("java.library.path");
+ sys_paths = initializePath("sun.boot.library.path");
+ }
+ if (isAbsolute) {
+ if (loadLibrary0(fromClass, new File(name))) {
+ return;
+ }
+ throw new UnsatisfiedLinkError("Can't load library: " + name);
+ }
+ if (loader != null) {
+ String libfilename = loader.findLibrary(name);
+ if (libfilename != null) {
+ File libfile = new File(libfilename);
+ if (!libfile.isAbsolute()) {
+ throw new UnsatisfiedLinkError(
+ "ClassLoader.findLibrary failed to return an absolute path: " + libfilename);
+ }
+ if (loadLibrary0(fromClass, libfile)) {
+ return;
+ }
+ throw new UnsatisfiedLinkError ("Can't load " + libfilename);
+ }
+ }
+ for (int i = 0 ; i < sys_paths.length ; i++) {
+ File libfile = new File(sys_paths[i], System.mapLibraryName(name));
+ if (loadLibrary0(fromClass, libfile)) {
+ return;
+ }
+ }
+ if (loader != null) {
+ for (int i = 0 ; i < usr_paths.length ; i++) {
+ File libfile = new File(usr_paths[i],
+ System.mapLibraryName(name));
+ if (loadLibrary0(fromClass, libfile)) {
+ return;
+ }
+ }
+ }
+ // Oops, it failed
+ throw new UnsatisfiedLinkError("no " + name + " in java.library.path");
+ }
+
+ private static boolean loadLibrary0(Class fromClass, final File file) {
+ Boolean exists = (Boolean)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(file.exists());
+ }
+ });
+ if (!exists.booleanValue()) {
+ return false;
+ }
+ String name;
+ try {
+ name = file.getCanonicalPath();
+ } catch (IOException e) {
+ return false;
+ }
+ ClassLoader loader =
+ (fromClass == null) ? null : fromClass.getClassLoader();
+ Vector libs =
+ loader != null ? loader.nativeLibraries : systemNativeLibraries;
+ synchronized (libs) {
+ int size = libs.size();
+ for (int i = 0; i < size; i++) {
+ NativeLibrary lib = (NativeLibrary)libs.elementAt(i);
+ if (name.equals(lib.name)) {
+ return true;
+ }
+ }
+
+ synchronized (loadedLibraryNames) {
+ if (loadedLibraryNames.contains(name)) {
+ throw new UnsatisfiedLinkError
+ ("Native Library " +
+ name +
+ " already loaded in another classloader");
+ }
+ /* If the library is being loaded (must be by
+ * the same thread, because Runtime.load and
+ * Runtime.loadLibrary are synchronous). The
+ * reason is can occur is that the JNI_OnLoad
+ * function can cause another loadLibrary call.
+ *
+ * Thus we can use a static stack to hold the list
+ * of libraries we are loading.
+ *
+ * If there is a pending load operation for the
+ * library, we immediately return success; otherwise,
+ * we raise UnsatisfiedLinkError.
+ */
+ int n = nativeLibraryContext.size();
+ for (int i = 0; i < n; i++) {
+ NativeLibrary lib = (NativeLibrary)
+ nativeLibraryContext.elementAt(i);
+ if (name.equals(lib.name)) {
+ if (loader == lib.fromClass.getClassLoader()) {
+ return true;
+ } else {
+ throw new UnsatisfiedLinkError
+ ("Native Library " +
+ name +
+ " is being loaded in another classloader");
+ }
+ }
+ }
+ NativeLibrary lib = new NativeLibrary(fromClass, name);
+ nativeLibraryContext.push(lib);
+ try {
+ lib.load(name);
+ } finally {
+ nativeLibraryContext.pop();
+ }
+ if (lib.handle != 0) {
+ loadedLibraryNames.addElement(name);
+ libs.addElement(lib);
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+
+ /* Called in the VM class linking code. */
+ static long findNative(ClassLoader loader, String name) {
+ Vector libs =
+ loader != null ? loader.nativeLibraries : systemNativeLibraries;
+ synchronized (libs) {
+ int size = libs.size();
+ for (int i = 0; i < size; i++) {
+ NativeLibrary lib = (NativeLibrary)libs.elementAt(i);
+ long entry = lib.find(name);
+ if (entry != 0)
+ return entry;
+ }
+ }
+ return 0;
+ }
+
+ /*
+ * The default toggle for assertion checking.
+ */
+ private boolean defaultAssertionStatus = false;
+
+ /*
+ * Maps String packageName to Boolean package default assertion status
+ * Note that the default package is placed under a null map key.
+ * If this field is null then we are delegating assertion status queries
+ * to the VM, i.e., none of this ClassLoader's assertion status
+ * modification methods have been called.
+ */
+ private Map packageAssertionStatus = null;
+
+ /*
+ * Maps String fullyQualifiedClassName to Boolean assertionStatus
+ * If this field is null then we are delegating assertion status queries
+ * to the VM, i.e., none of this ClassLoader's assertion status
+ * modification methods have been called.
+ */
+ Map classAssertionStatus = null;
+
+ /**
+ * Sets the default assertion status for this class loader. This setting
+ * determines whether classes loaded by this class loader and initialized
+ * in the future will have assertions enabled or disabled by default.
+ * This setting may be overridden on a per-package or per-class basis by
+ * invoking {@link #setPackageAssertionStatus(String,boolean)} or {@link
+ * #setClassAssertionStatus(String,boolean)}.
+ *
+ * @param enabled true if classes loaded by this class loader
+ * will henceforth have assertions enabled by default,
+ * false if they will have assertions disabled by default.
+ * @since 1.4
+ */
+ public synchronized void setDefaultAssertionStatus(boolean enabled) {
+ if (classAssertionStatus == null)
+ initializeJavaAssertionMaps();
+
+ defaultAssertionStatus = enabled;
+ }
+
+ /**
+ * Sets the package default assertion status for the named
+ * package. The package default assertion status determines the
+ * assertion status for classes initialized in the future that belong
+ * to the named package or any of its "subpackages."
+ *
+ * A subpackage of a package named p is any package whose name
+ * begins with "p." . For example, javax.swing.text is
+ * a subpackage of javax.swing, and both java.util
+ * and java.lang.reflect are subpackages of java.
+ *
+ * In the event that multiple package defaults apply to a given
+ * class, the package default pertaining to the most specific package
+ * takes precedence over the others. For example, if
+ * javax.lang and javax.lang.reflect both have
+ * package defaults associated with them, the latter package
+ * default applies to classes in javax.lang.reflect.
+ *
+ * Package defaults take precedence over the class loader's default
+ * assertion status, and may be overridden on a per-class basis by
+ * invoking {@link #setClassAssertionStatus(String,boolean)}.
+ *
+ * @param packageName the name of the package whose package default
+ * assertion status is to be set. A null value
+ * indicates the unnamed package that is "current"
+ * (JLS 7.4.2).
+ * @param enabled true if classes loaded by this classloader
+ * and belonging to the named package or any of its subpackages
+ * will have assertions enabled by default, false if they
+ * will have assertions disabled by default.
+ * @since 1.4
+ */
+ public synchronized void setPackageAssertionStatus(String packageName,
+ boolean enabled)
+ {
+ if (packageAssertionStatus == null)
+ initializeJavaAssertionMaps();
+
+ packageAssertionStatus.put(packageName, Boolean.valueOf(enabled));
+ }
+
+ /**
+ * Sets the desired assertion status for the named top-level class in
+ * this class loader and any nested classes contained therein.
+ * This setting takes precedence over the class loader's default
+ * assertion status, and over any applicable per-package default.
+ * This method has no effect if the named class has already been
+ * initialized. (Once a class is initialized, its assertion status cannot
+ * change.)
+ *