Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6611449

Internal Error thrown during generic method/constructor invocation

XMLWordPrintable

    • b25
    • generic
    • generic
    • Not verified

      Description:
         
      The following code fails during compilation with "internal error".
      <code>

      public class TypeInferenceTest<S>{

          public TypeInferenceTest() {

          this(1,1); //Throws internal error; cannot instanatiate ...
          //<Number>this(1,1); //Cannot find symbol
          // <Integer>this(1); //Cannot find symbol
          // this(1); //Cannot find symbol
          }
          public <T extends S> TypeInferenceTest(T a, T b) {
              //.....
          }
          public <T extends S> TypeInferenceTest(T a) {
             //....
          }

          <T extends S> void met1(T a,T b){
             met2 (1,1);//Throws internal error; cannot instanatiate ...
             new TypeInferenceTest<Number> ().met2 (1,1); //Compiles fine -- Type Inference works
      // met2(1); // Cannot find symbol
          }
          <T extends S> void met2(T a,T b){
              //..
          }

          <T extends S> void met2(T a){
             //...
          }

      }



      </code>

      Compilation result is :
      <output>

      TypeInferenceTest.java:5: internal error; cannot instantiate <T>TypeInferenceTest(T,T) at TypeInferenceTest<S> to ()
          this(1,1); //Throws internal error; cannot instanatiate ...
              ^
      TypeInferenceTest.java:18: internal error; cannot instantiate <T>met2(T,T) at TypeInferenceTest<S> to (int,int)
             Integer i = met2 (1,1);//Throws internal error; cannot instanatiate ...
                              ^
      2 errors


      </output>

      Tried in :
      <version>
      java version "1.7.0-internal"
      Java(TM) SE Runtime Environment (build 1.7.0-internal-jprtadm_26_Sep_2007_03_43-b00)
      Java HotSpot(TM) Server VM (build 11.0-b06, mixed mode)

      uname -a
      SunOS bonsai 5.11 snv_49 i86pc i386 i86pc

            mcimadamore Maurizio Cimadamore
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: