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

Dead phase should start after the shutdown hooks have executed

    Details

    • Subcomponent:
    • Resolved In Build:
      b56
    • CPU:
      x86
    • OS:
      windows_xp

      Description



      Name: rmT116609 Date: 05/20/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      In the enclosed program I have added a shutdown hook in premain() that provokes an assertion error when run using java. The program works OK when run under jdb.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the enclosed program:
      >javac -Xlint -source 1.5 -target 1.5 instrumentation\Instrument3.java

      It fails when run using

      >java -Xbootclasspath/p:. -javaagent:instrumentation.Instrument3 instrumentation.Instrument3

      and works when run using

      >jdb run

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Something like

      Hello World
      Shutdown Hook 865

      The actual output from jdb is:


      >jdb -J-Xbootclasspath/p:. -J-javaagent:instrumentation.Instrument3 instrumentation.Instrument3
      Initializing jdb ...
      > run
      run instrumentation.Instrument3
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Hello World

      The application exited
      Shutdown Hook 865

      >
      ACTUAL -
      >java -Xbootclasspath/p:. -javaagent:instrumentation.Instrument3 instrumentation.Instrument3
      Hello World
      *** java.lang.instrument ASSERTION FAILED ***: "!errorOccurred" at ../../../src/share/instrument/JPLISAgent.c line: 1067
      java.lang.InternalError
              at sun.instrument.InstrumentationImpl.getAllLoadedClasses0(Native Method)
              at sun.instrument.InstrumentationImpl.getAllLoadedClasses(InstrumentationImpl.java:86)
              at instrumentation.Instrument3+1.run(Instrument3.java:18)

      >

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      See above

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package instrumentation;

      import java.lang.instrument.ClassFileTransformer;
      import java.lang.instrument.IllegalClassFormatException;
      import java.lang.instrument.Instrumentation;

      public class Instrument3{

        private static Instrumentation inst;

        public static void premain(String options, Instrumentation ins) {
          inst = ins;
          
          // ins.addTransformer(new Logger() );
          Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
      System.err.println("Shutdown Hook " + inst.getAllLoadedClasses().length);
      }
            });
        }

        public static void main(String args[] ) {
          System.err.println("Hello World" );
        }

        public static class Logger implements ClassFileTransformer {
          public byte[] transform(java.lang.ClassLoader loader,
      java.lang.String className,
      java.lang.Class classBeingRedefined,
      java.security.ProtectionDomain protectionDomain,
      byte[] classfileBuffer) throws IllegalClassFormatException
          {
            // System.err.println(className);
            return null;
          }
        }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 270016)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              alanb Alan Bateman
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: