JDK-6986807 : TEST failure: java/beans/Introspector/TestTypeResolver.java - List should be List?
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.beans
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2010-09-22
  • Updated: 2011-02-07
  • Resolved: 2011-02-07
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Failed with JPRT sparc, but other platforms probably too.

This could be some kind of javac issue? Maybe?

--------------------------------------------------
TEST: java/beans/Introspector/TestTypeResolver.java
JDK under test: (/tmp/jprt/P2/T/182153.ss145989/testproduct/solaris_sparc_5.10-product)
java version "1.7.0-internal"
Java(TM) SE Runtime Environment (build 1.7.0-internal-jprtadm_2010_09_16_13_24-b00)
Java HotSpot(TM) Client VM (build 19.0-b06-201009161821.ss145989.tl-pit-2d-awt-swin, mixed mode, sharing)

ACTION: build -- Passed. Build successful
REASON: Named class compiled on demand
TIME:   0.192 seconds
messages:
command: build TestTypeResolver
reason: Named class compiled on demand
elapsed time (seconds): 0.192

ACTION: compile -- Passed. Compilation successful
REASON: .class file out of date or does not exist
TIME:   0.192 seconds
messages:
command: compile /tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java
reason: .class file out of date or does not exist
elapsed time (seconds): 0.192
direct:
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:30: warning: TypeResolver is internal proprietary API and may be removed in a future release
import com.sun.beans.TypeResolver;
                    ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:44: warning: GenericArrayTypeImpl is internal proprietary API and may be removed in a future release
import sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl;
                                             ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:45: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
                                             ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:110: warning: TypeResolver is internal proprietary API and may be removed in a future release
        t = TypeResolver.resolveInClass(c, t);
            ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:301: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:306: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:315: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:320: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:325: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:334: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:412: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
                ParameterizedTypeImpl.make(List.class, new Type[] {String.class}, null));
                ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:411: warning: GenericArrayTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = GenericArrayTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:416: warning: GenericArrayTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = GenericArrayTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:425: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:430: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:440: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:459: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:469: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:479: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:492: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:502: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
                        ParameterizedTypeImpl.make(
                        ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:499: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:513: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
                        ParameterizedTypeImpl.make(
                        ^
/tmp/jprt/P2/T/182153.ss145989/source/jdk/test/java/beans/Introspector/TestTypeResolver.java:510: warning: ParameterizedTypeImpl is internal proprietary API and may be removed in a future release
        static final Type expect = ParameterizedTypeImpl.make(
                                   ^
24 warnings

ACTION: main -- Failed. Execution failed: `main' threw exception: java.lang.Error: TEST FAILED
REASON: Assumed action based on file name: run main TestTypeResolver 
TIME:   0.051 seconds
messages:
command: main TestTypeResolver
reason: Assumed action based on file name: run main TestTypeResolver 
elapsed time (seconds): 0.051
STDOUT:
Test class TestTypeResolver
Test class TestTypeResolver$Bound
...T, as expected
Test class TestTypeResolver$BoundInt
...class java.lang.Integer, as expected
Test class TestTypeResolver$GenericArray
...java.util.List<java.lang.String>[], as expected
Test class TestTypeResolver$GenericArrayT
...T[], as expected
Test class TestTypeResolver$GenericArrayTSub
...class [[Ljava.lang.String;, as expected
Test class TestTypeResolver$Impl
...class java.lang.String, as expected
Test class TestTypeResolver$Impl2
...class java.lang.String, as expected
Test class TestTypeResolver$Int
...class java.lang.Integer, as expected
Test class TestTypeResolver$IntOverride
...class java.lang.Integer, as expected
Test interface TestTypeResolver$Intf
...T, as expected
Test class TestTypeResolver$ListInt
...java.util.List<java.lang.Integer>, as expected
Test class TestTypeResolver$ListIntSub
...java.util.List<java.lang.Integer>, as expected
Test class TestTypeResolver$ListListString
...java.util.List<java.util.List<java.lang.String>>, as expected
Test class TestTypeResolver$ListListT
...java.util.List<java.util.List<T>>, as expected
Test class TestTypeResolver$ListU
...java.util.List<U>, as expected
Test class TestTypeResolver$ListUInt
...java.util.List<java.lang.Integer>, as expected
Test class TestTypeResolver$ListUSub
...java.util.List<V>, as expected
Test class TestTypeResolver$ListUSubInt
...java.util.List<java.lang.Integer>, as expected
Test class TestTypeResolver$MethodParam
...T, as expected
Test class TestTypeResolver$Mid
...X, as expected
Test class TestTypeResolver$Outer
Test class TestTypeResolver$Outer$Inner
...T, as expected
Test class TestTypeResolver$Raw
...class java.lang.Object, as expected
Test class TestTypeResolver$RawBound
...class java.lang.Number, as expected
Test class TestTypeResolver$RawBoundInt
...class java.lang.Integer, as expected
Test class TestTypeResolver$RawSub
...class java.lang.Object, as expected
Test class TestTypeResolver$RawWildcardTSubSub
...java.util.List<? extends java.lang.Integer> BUT SHOULD BE interface java.util.List
Test class TestTypeResolver$SelfRef
...T, as expected
Test class TestTypeResolver$SelfRefSub
...class TestTypeResolver$SelfRefSub, as expected
Test class TestTypeResolver$SimpleArray
...class [Ljava.lang.String;, as expected
Test class TestTypeResolver$Str
...class java.lang.String, as expected
Test class TestTypeResolver$SubMap
...java.util.Map<java.lang.String, java.lang.Integer>, as expected
Test class TestTypeResolver$Super
...T, as expected
Test class TestTypeResolver$SuperMap
...java.util.Map<K, V>, as expected
Test class TestTypeResolver$TwoParams
...S, as expected
Test class TestTypeResolver$TwoParamsSub
...T, as expected
Test class TestTypeResolver$TwoParamsSubSub
...class java.lang.String, as expected
Test class TestTypeResolver$UExtendsT
...U, as expected
Test class TestTypeResolver$UExtendsTSub
...class java.lang.Integer, as expected
Test class TestTypeResolver$Wildcard
...java.util.List<?>, as expected
Test class TestTypeResolver$WildcardT
...java.util.List<? extends T>, as expected
Test class TestTypeResolver$WildcardTSub
...java.util.List<? extends java.lang.Integer>, as expected
Test class TestTypeResolver$WildcardTSubSub
...java.util.List<? extends java.lang.Integer>, as expected
Test class TestTypeResolver$WildcardTSuper
...java.util.List<? super T>, as expected
Test class TestTypeResolver$WildcardTSuperSub
...java.util.List<? super java.lang.Integer>, as expected
TEST FAILED: failed cases: [class TestTypeResolver$RawWildcardTSubSub]
STDERR:
java.lang.Error: TEST FAILED
	at TestTypeResolver.main(TestTypeResolver.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:613)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
	at java.lang.Thread.run(Thread.java:729)

JavaTest Message: Test threw exception: java.lang.Error
JavaTest Message: shutting down test


TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.Error: TEST FAILED
--------------------------------------------------

Comments
EVALUATION I was looking for changes in the wrong place. I see that 6337171 was integrated in b112, which is where this test started failing. That means that the class hierarchy in the test has acquired extra synthetic methods, which is presumably why TypeResolver is reacting differently. With the latest builds, it appears that compiler considers that the return type of RawWildcardTSubSub is neither List (which the test currently expects) nor List<? extends String> (which TypeResolver now returns), but Object. I am inclined to think that fixing this bizarre mix of raw types and type parameters is more trouble than it's worth, and the RawWildcardTSubSub case should just be commented out.
08-10-2010

EVALUATION I believe the test is wrong and should be adjusted so that it expects the type List<? extends Integer> rather than List here. I don't know what changed to cause the test to start failing, though. Here's a summary of what's happening. This is a particularly tortuous test that attempts to exercise the equally tortuous code in TypeResolver. The problem that code is solving happens when you have a parent class or interface such as List<E> and a concrete subclass such as ArrayList<String>. If you use reflection to look at a method such as get(int) in the subclass you will that its return type is still E. It's the compiler that expands E into String when someone calls the method. So if you're using reflection you need a way to do the same expansion yourself, and that's what TypeResolver does. The test case that is failing is the result of this set of declarations (basically): static class Super<T> { public T getThing() { return null; } } static class WildcardT<T> extends Super<List<? extends T>> {} static class WildcardTSub extends WildcardT<Integer> {} static class WildcardTSubSub<X> extends WildcardTSub {} static class RawWildcardTSubSub extends WildcardTSubSub {} The test is asking the TypeResolver for the type of getThing() in the class RawWildcardTSubSub and expecting it to be raw List. It is failing because the TypeResolver is actually saying that the type is List<? extends Integer>. If you follow the chain of superclasses it does indeed seem that the type should be List<? extends Integer>. My dim recollection is that when I wrote the test a few years ago I was reasoning that, because RawWildcardTSubSub has a raw superclass (it does not supply the required type parameter to WildcardTSubSub), its methods have their return types erased. However, experimenting with the compiler shows that this is not true. You can assign "new RawWildcardTSubSub().getThing()" to a List<? extends Integer> without any diagnostics, and if you try to assign it to a List<? extends String> you get an error telling you that List<? extends Integer> cannot be assigned to List<? extends String>. Therefore getThing() has not in fact been erased. This is true even in the JDK 5 compiler, so I think the expectation was always wrong. Since the test passed up until now, apparently the TypeResolver was wrong in this case. It's now right, so the test should be adjusted accordingly. I do not see any recent changes that could explain this change, however, so I admit I do not fully understand what is happening here.
05-10-2010