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

Javap output for static variables referenced from other classes confusing

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.0
    • tools
    • mantis
    • x86
    • windows_2000



      Name: nt126004 Date: 04/19/2002


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

      And
      java version "1.3.1_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
      Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      The output of javap -c on reference to static fields is
      misleading. It should contain the containing class.

      (This is undenialy minor but I wasted a bunch of time
      tying to find a field that actually lives in another class.
      And javap trivially knows this.)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. javap -c <ClassThatReferencesStaticField>

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      It would be nice to see the containing class.

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Code
      public class StaticTest{
          public StaticTest(){
              java.io.InputStream is = System.in;
          }
      }

      >javap -c StaticTest
      Compiled from StaticTest.java
      public class StaticTest extends java.lang.Object {
          public StaticTest();
      }

      Method StaticTest()
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 getstatic #2 <Field java.io.InputStream in> // On what class!?!?!?
         7 astore_1
         8 return
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      - Look at source code
      - grep for 'classname looking things' in class file (and then javap)
      - Write one's own (which admittedly is not terribly difficult)
      ...
      (Review ID: 144365)
      ======================================================================

            duke J. Duke
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: