diff --git a/boundbox-library-integration-tests/src/main/java/org/boundbox/sample/NonStaticInnerClassInheritsStaticInnerClassTestClass.java b/boundbox-library-integration-tests/src/main/java/org/boundbox/sample/NonStaticInnerClassInheritsStaticInnerClassTestClass.java index 922ab71..983909f 100644 --- a/boundbox-library-integration-tests/src/main/java/org/boundbox/sample/NonStaticInnerClassInheritsStaticInnerClassTestClass.java +++ b/boundbox-library-integration-tests/src/main/java/org/boundbox/sample/NonStaticInnerClassInheritsStaticInnerClassTestClass.java @@ -7,9 +7,9 @@ public class NonStaticInnerClassInheritsStaticInnerClassTestClass { //this test is order dependent, that's a fail. //there is absolutely nothing that we can do to prevent this. private static class StaticInnerClass { - public static int foo = 2; + private static int foo = 2; } public class InnerClass extends StaticInnerClass { - }; + } } diff --git a/boundbox-library/src/main/java/org/boundbox/processor/BoundClassScanner.java b/boundbox-library/src/main/java/org/boundbox/processor/BoundClassScanner.java index 828675d..2f05748 100644 --- a/boundbox-library/src/main/java/org/boundbox/processor/BoundClassScanner.java +++ b/boundbox-library/src/main/java/org/boundbox/processor/BoundClassScanner.java @@ -69,10 +69,6 @@ public Void visitTypeAsClass(TypeElement e, ScanningContext scanningContext) { return null; } - if (visitiedTypes.contains(e.toString())) { - log.info("dropping visitied class ->" + e.getSimpleName()); - return null; - } visitiedTypes.add(e.toString()); doCheckVisibilityOfType(e); diff --git a/boundbox-library/src/test/java/org/boundbox/processor/BoundBoxProcessorTest.java b/boundbox-library/src/test/java/org/boundbox/processor/BoundBoxProcessorTest.java index b58b687..7300190 100644 --- a/boundbox-library/src/test/java/org/boundbox/processor/BoundBoxProcessorTest.java +++ b/boundbox-library/src/test/java/org/boundbox/processor/BoundBoxProcessorTest.java @@ -1173,6 +1173,30 @@ public void testProcess_class_with_non_static_inner_class_inheriting_fields_from FieldInfoFoo.setEffectiveInheritanceLevel(0); assertContains(listFieldInfos, FieldInfoFoo); } + + @Test + public void testProcess_class_with_non_static_inner_class_inheriting_fields_from_a_static_inner_class_in_same_outer_class() throws URISyntaxException { + // given + String[] testSourceFileNames = new String[] { "TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.java" }; + CompilationTask task = processAnnotations(testSourceFileNames, boundBoxProcessor); + + // when + // Perform the compilation task. + task.call(); + + // then + assertFalse(boundBoxProcessor.getListClassInfo().isEmpty()); + ClassInfo classInfo = boundBoxProcessor.getListClassInfo().get(0); + + List listFieldInfos = classInfo.getListInnerClassInfo().get(1).getListFieldInfos(); + + FieldInfo FieldInfoFoo = new FieldInfo("foo", int.class.getName()); + FieldInfoFoo.setStaticField(false); + FieldInfoFoo.setInheritanceLevel(1); + FieldInfoFoo.setEffectiveInheritanceLevel(0); + assertContains(listFieldInfos, FieldInfoFoo); + } + @Test public void testProcess_class_with_composition_of_static_inner_class() throws URISyntaxException { diff --git a/boundbox-library/src/test/resources/TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.java b/boundbox-library/src/test/resources/TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.java index 628cfee..96181ff 100644 --- a/boundbox-library/src/test/resources/TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.java +++ b/boundbox-library/src/test/resources/TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.java @@ -1,16 +1,12 @@ import org.boundbox.BoundBox; -//Thanks to Philippe Prados for this nasty example -@BoundBox(boundClass = TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.StaticInner.class) -@SuppressWarnings("unused") +//TDD for issue #18 +@BoundBox(boundClass = TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass.InnerClass.class) public class TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass { - public class InnerClass { - private int foo = 2; + public class InnerClass extends StaticInner { } - public static class StaticInner extends InnerClass { - public StaticInner(TestClassIsNonStaticInnerClassThatExtendsStaticInnerClass obj) { - obj.super(); - } + public static class StaticInner { + public static int foo = 2; } } diff --git a/boundbox-library/src/test/resources/TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.java b/boundbox-library/src/test/resources/TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.java index 681b408..2b2ddf7 100644 --- a/boundbox-library/src/test/resources/TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.java +++ b/boundbox-library/src/test/resources/TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.java @@ -1,12 +1,16 @@ import org.boundbox.BoundBox; -//TDD for issue #18 -@BoundBox(boundClass = TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.InnerClass.class) +//Thanks to Philippe Prados for this nasty example +@BoundBox(boundClass = TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass.StaticInner.class) +@SuppressWarnings("unused") public class TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass { - public class InnerClass extends StaticInner { + public class InnerClass { + private int foo = 2; } - public static class StaticInner { - public static int foo = 2; + public static class StaticInner extends InnerClass { + public StaticInner(TestClassIsStaticInnerClassThatExtendsNonStaticInnerClass obj) { + obj.super(); + } } } diff --git a/boundbox-library/src/test/resources/TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.java b/boundbox-library/src/test/resources/TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.java new file mode 100644 index 0000000..6e10bbb --- /dev/null +++ b/boundbox-library/src/test/resources/TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.java @@ -0,0 +1,14 @@ +import org.boundbox.BoundBox; + +//TDD for issue #18 +@SuppressWarnings("unused") +@BoundBox(boundClass = TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass.class) +public class TestClassWithNonStaticInnerClassInheritingStaticInnerClassInSameOuterClass { + + public static class StaticInner { + private static int foo = 2; + } + public class SubInnerClass extends StaticInner { + } +} +