< prev index next >

test/hotspot/jtreg/gc/stress/gcbasher/Decompiler.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 26,11 ***
  
  class Decompiler {
      private ByteCursor cursor;
      private ClassInfo ci;
  
!     public Decompiler(byte[] classData) {
          cursor = new ByteCursor(classData);
  
          int magicNumber = cursor.readInt();
          if (magicNumber != 0xCAFEBABE) {
              throw new IllegalArgumentException("Bad magic number " + magicNumber);
--- 26,11 ---
  
  class Decompiler {
      private ByteCursor cursor;
      private ClassInfo ci;
  
!     public Decompiler(Byte[] classData) {
          cursor = new ByteCursor(classData);
  
          int magicNumber = cursor.readInt();
          if (magicNumber != 0xCAFEBABE) {
              throw new IllegalArgumentException("Bad magic number " + magicNumber);

*** 67,11 ***
      private boolean isDependency(String name, String className) {
          return !name.equals(className) && !name.startsWith("[");
      }
  
      private void addDependency(MethodInfo m, String name) {
!         Dependency d = new Dependency(m.getName(), m.getDescriptor(), name);
          ci.addResolutionDep(d);
      }
  
      private String resolveName(ConstantPoolEntry[] constantPool, int cpi) {
          int nameIndex = constantPool[cpi].getNameIndex();
--- 67,11 ---
      private boolean isDependency(String name, String className) {
          return !name.equals(className) && !name.startsWith("[");
      }
  
      private void addDependency(MethodInfo m, String name) {
!         Dependency d = new Dependency(m.name(), m.descriptor(), name);
          ci.addResolutionDep(d);
      }
  
      private String resolveName(ConstantPoolEntry[] constantPool, int cpi) {
          int nameIndex = constantPool[cpi].getNameIndex();

*** 79,13 ***
      }
  
      private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[] constantPool) {
          for (int i = 0; i < methods.length; i++) {
              MethodInfo m = methods[i];
!             final int stopCheck = m.getCodeStart() + m.getCodeLength();
  
!             int byteCodeIndex = m.getCodeStart();
              while (byteCodeIndex < stopCheck) {
                  int bc = cursor.readUnsignedByteAt(byteCodeIndex);
  
                  switch (bc) {
                      // These opcodes cause name resolution or initialization
--- 79,13 ---
      }
  
      private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[] constantPool) {
          for (int i = 0; i < methods.length; i++) {
              MethodInfo m = methods[i];
!             final int stopCheck = m.codeStart() + m.codeLength();
  
!             int byteCodeIndex = m.codeStart();
              while (byteCodeIndex < stopCheck) {
                  int bc = cursor.readUnsignedByteAt(byteCodeIndex);
  
                  switch (bc) {
                      // These opcodes cause name resolution or initialization

*** 124,11 ***
                          break;
                      }
  
                      case Bytecode.LOOKUPSWITCH: {
                          byteCodeIndex++;
!                         int offset = byteCodeIndex - m.getCodeStart();
                          while (offset % 4 != 0) {
                              offset++;
                              byteCodeIndex++;
                          }
  
--- 124,11 ---
                          break;
                      }
  
                      case Bytecode.LOOKUPSWITCH: {
                          byteCodeIndex++;
!                         int offset = byteCodeIndex - m.codeStart();
                          while (offset % 4 != 0) {
                              offset++;
                              byteCodeIndex++;
                          }
  

*** 141,11 ***
                          continue;
                      }
  
                      case Bytecode.TABLESWITCH: {
                          byteCodeIndex++;
!                         int offset = byteCodeIndex - m.getCodeStart();
                          while (offset % 4 != 0) {
                              offset++;
                              byteCodeIndex++;
                          }
  
--- 141,11 ---
                          continue;
                      }
  
                      case Bytecode.TABLESWITCH: {
                          byteCodeIndex++;
!                         int offset = byteCodeIndex - m.codeStart();
                          while (offset % 4 != 0) {
                              offset++;
                              byteCodeIndex++;
                          }
  

*** 173,11 ***
  
                  byteCodeIndex += Bytecode.getLength(bc);
              }
  
              if (byteCodeIndex - stopCheck > 1) {
!                 String err = "bad finish for method " + m.getName() +
                               "End + "  + (byteCodeIndex - stopCheck);
                  throw new IllegalArgumentException(err);
              }
          }
      }
--- 173,11 ---
  
                  byteCodeIndex += Bytecode.getLength(bc);
              }
  
              if (byteCodeIndex - stopCheck > 1) {
!                 String err = "bad finish for method " + m.name() +
                               "End + "  + (byteCodeIndex - stopCheck);
                  throw new IllegalArgumentException(err);
              }
          }
      }

*** 189,12 ***
              cursor.readUnsignedShort(); // access flags
  
              String name = constantPool[cursor.readUnsignedShort()].getValue();
              String descriptor = constantPool[cursor.readUnsignedShort()].getValue();
  
!             int codeLength = 0;
!             int codeStart = 0;
  
              int numAttributes = cursor.readUnsignedShort(); // attributes count
              for (int j = 0; j < numAttributes; j++) {
                  int type = cursor.readUnsignedShort(); // attrib nameIndex
                  int aLen = cursor.readInt(); // attrib length
--- 189,12 ---
              cursor.readUnsignedShort(); // access flags
  
              String name = constantPool[cursor.readUnsignedShort()].getValue();
              String descriptor = constantPool[cursor.readUnsignedShort()].getValue();
  
!             Integer codeLength = 0;
!             Integer codeStart = 0;
  
              int numAttributes = cursor.readUnsignedShort(); // attributes count
              for (int j = 0; j < numAttributes; j++) {
                  int type = cursor.readUnsignedShort(); // attrib nameIndex
                  int aLen = cursor.readInt(); // attrib length
< prev index next >