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

VerifyError with double Assignment using a Generic Member of a Superclass

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 8
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b93
    • CPU:
      x86
    • OS:
      windows_7
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      OS-X/Windows: javac 1.6.0_24
      OS-X: openjdk-1.7-x86_64 javac 1.7.0-ea
      Windows: javac 1.7.0-internal

      ADDITIONAL OS VERSION INFORMATION :
      Windows7-64 Bit
      OS-X 10.6.7
      probably any OS

      A DESCRIPTION OF THE PROBLEM :
      Given a Paramterized Subclass A<D> with a Member D d and a Method D getD(). A Subclass B extends A with a concrete Class (say Integer) and a Member y.

      The double Assigmenet
       y = d = getD();
      will result in a Byte code not accepted by the Verifier:
      With JDK 1.6
      java.lang.VerifyError: (class: test/problem/B, method: <init> signature: ()V)
      Bad type in put field/putstatic

      With JDK 1.7
      java.lang.VerifyError: Bad type on operand stack in method test.problem.B.<init>()V at offset 14







      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute problem.sh:
      #!/bin/bash
      # problem
      $JAVA_HOME/bin/javac -version
      rm -Rf bin/*
      $JAVA_HOME/bin/javac -Xlint:unchecked -g src/test/problem/*.java -d bin
      $JAVA_HOME/bin/java -cp bin test.problem.B

      OR problem.bat
      %JAVA_HOME%\bin\javac -version
      mkdir bin
      del /S /Q bin\*
      %JAVA_HOME%\bin\javac -Xlint:unchecked -g src/test/problem/*.java -d bin
      %JAVA_HOME%\bin\java -cp bin test.problem.B

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No Exceptions
      ACTUAL -
      OS-X 10.6.7
      ./problem.sh
      javac 1.6.0_24
      Exception in thread "main" java.lang.VerifyError: (class: test/problem/B, method: <init> signature: ()V) Bad type in putfield/putstatic

      $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-1.7-x86_64/Contents/Home
      $ ./problem.sh javac 1.7.0-internal
      Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method test.problem.B.<init>()V at offset 14
      at java.lang.Class.getDeclaredMethods0(Native Method)
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
      at java.lang.Class.getMethod0(Class.java:2685)
      at java.lang.Class.getMethod(Class.java:1620)
      at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:484)
      at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)

      problem
      javac 1.6.0_24
      Ein Unterverzeichnis oder eine Datei mit dem Namen "bin" existiert bereits.
      Datei wurde gelöscht - D:\Develop\clean-code\Problem\bin\test\problem\A.class
      Datei wurde gelöscht - D:\Develop\clean-code\Problem\bin\test\problem\B.class
      Exception in thread "main" java.lang.VerifyError: (class: test/problem/B, method: <init> signature: ()V) Bad type in put
      field/putstatic
      Could not find the main class: test.problem.B. Program will exit.

      Windows7 64-Bit
      >problem
      javac 1.7.0-ea
      Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method test.problem.B.<init>()V at offset
      14
             at java.lang.Class.getDeclaredMethods0(Native Method)
             at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
             at java.lang.Class.getMethod0(Class.java:2685)
             at java.lang.Class.getMethod(Class.java:1620)
             at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:484)
             at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.VerifyError: (class: test/problem/B, method: <init> signature: ()V) Bad type in putfield/putstatic

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test.problem;

      class A<D> {

      D d;

      D getD() {
      return null;
      }
      }

      class B extends A<Integer> {

      Integer y;

      B() {
      y = d = getD(); // Verify Error here
      }

      public static void main(String[] args) {
      new B();
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use single assignments.

      It took me some 2 hours to boil down the Problem to this simple level.
      One may get lost when it happens as part of some complex code.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              vromero Vicente Arturo Romero Zaldivar
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: