991 throw exc; |
991 throw exc; |
992 } |
992 } |
993 return minorVersion; |
993 return minorVersion; |
994 } |
994 } |
995 |
995 |
996 private void getConstantPoolInfo() { |
996 private byte[] getConstantPoolInfo() { |
997 JDWP.ReferenceType.ConstantPool jdwpCPool; |
997 JDWP.ReferenceType.ConstantPool jdwpCPool; |
998 if (!vm.canGetConstantPool()) { |
998 if (!vm.canGetConstantPool()) { |
999 throw new UnsupportedOperationException(); |
999 throw new UnsupportedOperationException(); |
1000 } |
1000 } |
1001 if (constantPoolInfoGotten) { |
1001 if (constantPoolInfoGotten) { |
1002 return; |
1002 if (constantPoolBytesRef == null) { |
1003 } else { |
1003 return null; |
1004 try { |
1004 } |
1005 jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); |
1005 byte[] cpbytes = constantPoolBytesRef.get(); |
1006 } catch (JDWPException exc) { |
1006 if (cpbytes != null) { |
1007 if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { |
1007 return cpbytes; |
1008 constanPoolCount = 0; |
1008 } |
1009 constantPoolBytesRef = null; |
1009 } |
1010 constantPoolInfoGotten = true; |
1010 |
1011 return; |
1011 try { |
1012 } else { |
1012 jdwpCPool = JDWP.ReferenceType.ConstantPool.process(vm, this); |
1013 throw exc.toJDIException(); |
1013 } catch (JDWPException exc) { |
1014 } |
1014 if (exc.errorCode() == JDWP.Error.ABSENT_INFORMATION) { |
1015 } |
1015 constanPoolCount = 0; |
1016 byte[] cpbytes; |
1016 constantPoolBytesRef = null; |
1017 constanPoolCount = jdwpCPool.count; |
1017 constantPoolInfoGotten = true; |
1018 cpbytes = jdwpCPool.bytes; |
1018 return null; |
1019 constantPoolBytesRef = new SoftReference<byte[]>(cpbytes); |
1019 } else { |
1020 constantPoolInfoGotten = true; |
1020 throw exc.toJDIException(); |
1021 } |
1021 } |
|
1022 } |
|
1023 byte[] cpbytes; |
|
1024 constanPoolCount = jdwpCPool.count; |
|
1025 cpbytes = jdwpCPool.bytes; |
|
1026 constantPoolBytesRef = new SoftReference<byte[]>(cpbytes); |
|
1027 constantPoolInfoGotten = true; |
|
1028 return cpbytes; |
1022 } |
1029 } |
1023 |
1030 |
1024 public int constantPoolCount() { |
1031 public int constantPoolCount() { |
1025 try { |
1032 try { |
1026 getConstantPoolInfo(); |
1033 getConstantPoolInfo(); |
1029 } |
1036 } |
1030 return constanPoolCount; |
1037 return constanPoolCount; |
1031 } |
1038 } |
1032 |
1039 |
1033 public byte[] constantPool() { |
1040 public byte[] constantPool() { |
|
1041 byte[] cpbytes; |
1034 try { |
1042 try { |
1035 getConstantPoolInfo(); |
1043 cpbytes = getConstantPoolInfo(); |
1036 } catch (RuntimeException exc) { |
1044 } catch (RuntimeException exc) { |
1037 throw exc; |
1045 throw exc; |
1038 } |
1046 } |
1039 if (constantPoolBytesRef != null) { |
1047 if (cpbytes != null) { |
1040 byte[] cpbytes = constantPoolBytesRef.get(); |
|
1041 /* |
1048 /* |
1042 * Arrays are always modifiable, so it is a little unsafe |
1049 * Arrays are always modifiable, so it is a little unsafe |
1043 * to return the cached bytecodes directly; instead, we |
1050 * to return the cached bytecodes directly; instead, we |
1044 * make a clone at the cost of using more memory. |
1051 * make a clone at the cost of using more memory. |
1045 */ |
1052 */ |