Community
Participate
Working Groups
See attached patch for a failing junit test case.
Created attachment 30689 [details] adds a failing test case to TestJava5ReflectionBasedReferenceTypeDelegate
This test fails on the Java 1.5 reflection delegate impl, since it returns a missing type (which is clearly wrong). If you move this test to the Java reflection delegate impl, it throws an NPE, since that implementation has the superclass of java.io.Serializable as null. The javadoc comment in ResolvedType.getSuperclass doesn't specify what the superclass of a top-level interface should be. If null is the right superclass here, then the test should just assertNull :-)
Created attachment 30691 [details] Put tests for null superclass into base reflection delegate test not just the 1.5 tests Adds more tests and moves tests to base test case. Supersedes previous test case.
Created attachment 30692 [details] fixes the problem: checks for any class with a null superclass, even an interface
It looks like the superclass behavior is inconsistent between Java's notion of the superclass and BCEL's. This test fails: public void testGenericInterfaceSuperclass() { BcelWorld world = new BcelWorld(); world.setBehaveInJava5Way(true); UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map"); ResolvedType rtx = world.resolve(javaUtilMap); assertNull(rtx.getSuperclass()); } The rtx.getSuperclass() result is Object... I discovered this because my patch caused an NPE in ReferenceType.getSuperclass() ...
The reflection based stuff is intended to be a drop in replacement for the bcel stuff. Therefore we need the reflection stuff to return the same as bcel. So, I've modified the reflection code to return a superclass of Object rather than NULL - except for primitive types where it is null (bcel returns null in these cases too). I modified Rons supplied test programs to verify consistency across the bcel world and reflection world. fixes checked in.
Created attachment 30714 [details] Fixes pre-1.5 reflection delegate to be consistent by returning Object as the superclass of an interface. This works for the 1.5 implementation but the pre-1.5 code was still breaking. This updated patch fixes the pre-1.5 implementation
Created attachment 30715 [details] Patch to remove the 1.5-specific test from the weaver project This test relies on Java 5 and was breaking on the earlier Java versions.
Created attachment 30716 [details] Patch to add the 1.5-specific test to the weaver5 project test case instead These 3 patches fix the pre-1.5 reflection implementation and move tests around to work properly for both pre-1.5 and 1.5.
oops, silly me - hurrying and I've made mistakes. I've applied those changes. Can you possibly create patches at the module level rather than the file level Ron? They are much easier for me to work with.
fix available.