Bug 118192

Summary: Missing superclass for java.io.Serializable in reflection 1.5 delegate impl
Product: [Tools] AspectJ Reporter: Ron Bodkin <rbodkin+LISTS>
Component: CompilerAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: DEVELOPMENT   
Target Milestone: 1.5.0RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
adds a failing test case to TestJava5ReflectionBasedReferenceTypeDelegate
none
Put tests for null superclass into base reflection delegate test not just the 1.5 tests
aclement: iplog+
fixes the problem: checks for any class with a null superclass, even an interface
aclement: iplog+
Fixes pre-1.5 reflection delegate to be consistent by returning Object as the superclass of an interface.
aclement: iplog+
Patch to remove the 1.5-specific test from the weaver project
aclement: iplog+
Patch to add the 1.5-specific test to the weaver5 project test case instead aclement: iplog+

Description Ron Bodkin CLA 2005-11-28 02:07:52 EST
See attached patch for a failing junit test case.
Comment 1 Ron Bodkin CLA 2005-11-28 02:10:43 EST
Created attachment 30689 [details]
adds a failing test case to TestJava5ReflectionBasedReferenceTypeDelegate
Comment 2 Ron Bodkin CLA 2005-11-28 02:16:14 EST
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 :-)


Comment 3 Ron Bodkin CLA 2005-11-28 02:33:55 EST
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.
Comment 4 Ron Bodkin CLA 2005-11-28 02:35:46 EST
Created attachment 30692 [details]
fixes the problem: checks for any class with a null superclass, even an interface
Comment 5 Ron Bodkin CLA 2005-11-28 02:45:21 EST
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() ...
Comment 6 Andrew Clement CLA 2005-11-28 10:55:26 EST
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.
Comment 7 Ron Bodkin CLA 2005-11-28 12:12:21 EST
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
Comment 8 Ron Bodkin CLA 2005-11-28 12:14:23 EST
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.
Comment 9 Ron Bodkin CLA 2005-11-28 12:16:40 EST
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.
Comment 10 Andrew Clement CLA 2005-11-28 12:43:54 EST
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.
Comment 11 Andrew Clement CLA 2005-11-29 05:18:30 EST
fix available.