JDK-6946618 : sqe test fails: javac/generics/NewOnTypeParm in pit jdk7 b91 in all platforms.
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2010-04-23
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b97Fixed
Related Reports
Relates :  
Description
sqe test fails in pit jdk7 b91 in all platforms.
javac/generics/NewOnTypeParm  

sqe test location:
/net/sqenfs-1/export1/comp/jsn/all_workspace/7_int/tools/src/javac/generics/NewOnTypeParm 
 
                 D.java              NewOnTypeParm.ksh
                NewOnTypeParm.cfg


fails in solaris/linux and windows platforms.

result: of pit testing for solaris is:
http://sqeweb.sfbay.sun.com/net/sqenfs-2/export2/results/tools/pit/7/b91/solaris10-sparc_c1/results-jsn-sfv245-1-10-04-22-23-33/results/pande.SunOS.sparc/NewOnTypeParm/
http://sqeweb.sfbay.sun.com/net/sqenfs-2/export2/results/tools/pit/7/b91/solaris10-sparc_c1/results-jsn-sfv245-1-10-04-22-23-33/results/pande.SunOS.sparc/NewOnTypeParm/NewOnTypeParm.err

standalone testouput:
--------------------
jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 55 %
 uname -a

SunOS jsn-sfv245-1 5.10 Generic_127127-11 sun4u sparc SUNW,Sun-Fire-V245

jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 56 %
 java -version

java version "1.7.0-internal"
Java(TM) SE Runtime Environment (build 1.7.0-internal-jprtadm_2010_04_20_18_25-b00)
Java HotSpot(TM) Server VM (build 18.0-b02-2010-04-20-235308.ss145989.tl-pit-2d-awt-swing, mixed mode)

test code:
---------

jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 54 % cat D.java
class C<T> {
  T makeT() {
    return new T();
  }
}

class D<S> {
  C<S> makeC() {
    return new C<S>();
  }
}



jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 51 % 
javac -source 1.5 -d . D.java

An exception has occurred in the compiler (1.7.0-internal). Please file a bug at
 the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after ch
ecking the Bug Parade for duplicates. Include your program and the following dia
gnostic in your report.  Thank you.
java.lang.ClassCastException: com.sun.tools.javac.code.Type$TypeVar cannot be ca
st to com.sun.tools.javac.code.Type$ClassType
        at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1468)
        at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1350)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:417)
        at com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1216)
        at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1218)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:808)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:768)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:729)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:655)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2993)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2916)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2852)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:112
2)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:842)

        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:801)
        at com.sun.tools.javac.main.Main.compile(Main.java:412)
        at com.sun.tools.javac.main.Main.compile(Main.java:330)
        at com.sun.tools.javac.main.Main.compile(Main.java:321)
        at com.sun.tools.javac.Main.compile(Main.java:82)
        at com.sun.tools.javac.Main.main(Main.java:67)


jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 53 %
 javac *.java

An exception has occurred in the compiler (1.7.0-internal). Please file a bug at
 the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after ch
ecking the Bug Parade for duplicates. Include your program and the following dia
gnostic in your report.  Thank you.
java.lang.ClassCastException: com.sun.tools.javac.code.Type$TypeVar cannot be ca
st to com.sun.tools.javac.code.Type$ClassType
        at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1468)
        at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1350)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:417)
        at com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1216)
        at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1218)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:460)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:808)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:768)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:729)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:655)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:400)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:444)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2993)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2916)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2852)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:112
2)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:842)

        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:801)
        at com.sun.tools.javac.main.Main.compile(Main.java:412)
        at com.sun.tools.javac.main.Main.compile(Main.java:330)
        at com.sun.tools.javac.main.Main.compile(Main.java:321)
        at com.sun.tools.javac.Main.compile(Main.java:82)
        at com.sun.tools.javac.Main.main(Main.java:67)




==============================promotion jdk7 b90 output is as epected ok===========
jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 81 % javac *.java
D.java:3: unexpected type
    return new T();
               ^
  required: class
  found:    type parameter T
  where T is a type-variable:
    T extends Object declared in class C
1 error
jsn-sfv245-1:/net/sqenfs-2/export2/results/tools/test/pit/7/b91 82 % javac -source 1.5 *.java
D.java:3: unexpected type
    return new T();
               ^
  required: class
  found:    type parameter T
  where T is a type-variable:
    T extends Object declared in class C
1 error
============================

Comments
SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/2881b376a689
19-05-2010

EVALUATION This is a regression caused by the new diamond implementation (see CR 6939620). There's a cast to ClassType that is not always guaranteed to succeed in corner cases like this, where the type of the instance creation expression is not a class type. Simple fix.
23-04-2010