/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
implements ReferenceType {
protected long ref;
private boolean genericSignatureGotten = false;
private boolean isClassLoaderCached = false;
private boolean isPrepared = false;
private boolean versionNumberGotten = false;
private int majorVersion;
private int minorVersion;
private boolean constantPoolInfoGotten = false;
private int constanPoolCount;
private byte[] constantPoolBytes;
/* to mark a SourceFile request that returned a genuine JDWP.Error.ABSENT_INFORMATION */
/* to mark when no info available */
// bits set when initialization was attempted (succeeded or failed)
private static final int INITIALIZED_OR_FAILED =
super(aVm);
genericSignatureGotten = false;
}
void noticeRedefineClass() {
//Invalidate information previously fetched and cached.
//These will be refreshed later on demand.
modifiers = -1;
methodsRef = null;
versionNumberGotten = false;
constantPoolInfoGotten = false;
}
if (ref == 0) {
// obsolete method
return new ObsoleteMethodImpl(vm, this);
}
// Fetch all methods for the class, check performance impact
// Needs no synchronization now, since methods() returns
// unmodifiable local data
return method;
}
}
}
// Fetch all fields for the class, check performance impact
// Needs no synchronization now, since fields() returns
// unmodifiable local data
return field;
}
}
}
} else {
return false;
}
}
public int hashCode() {
return(int)ref();
}
/*
* Note that it is critical that compareTo() == 0
* implies that equals() == true. Otherwise, TreeSet
* will collapse classes.
*
* (Classes of the same name loaded by different class loaders
* or in different VMs must not return 0).
*/
if (comp == 0) {
// optimize for typical case: refs equal and VMs equal
// sequenceNumbers are always positive
} else {
}
}
return comp;
}
// Does not need synchronization, since worst-case
// static info is fetched twice
if (vm.canGet1_5LanguageFeatures()) {
/*
* we might as well get both the signature and the
* generic signature.
*/
} else {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
}
return signature;
}
// This gets both the signature and the generic signature
// Does not need synchronization, since worst-case
// static info is fetched twice
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
return genericSignature;
}
if (!isClassLoaderCached) {
// Does not need synchronization, since worst-case
// static info is fetched twice
try {
isClassLoaderCached = true;
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
return classLoader;
}
public boolean isPublic() {
if (modifiers == -1)
getModifiers();
}
public boolean isProtected() {
if (modifiers == -1)
getModifiers();
}
public boolean isPrivate() {
if (modifiers == -1)
getModifiers();
}
public boolean isPackagePrivate() {
}
public boolean isAbstract() {
if (modifiers == -1)
getModifiers();
}
public boolean isFinal() {
if (modifiers == -1)
getModifiers();
}
public boolean isStatic() {
if (modifiers == -1)
getModifiers();
}
public boolean isPrepared() {
// This ref type may have been prepared before we were getting
// events, so get it once. After that,
// this status flag is updated through the ClassPrepareEvent,
// there is no need for the expense of a JDWP query.
if (status == 0) {
updateStatus();
}
return isPrepared;
}
public boolean isVerified() {
// Once true, it never resets, so we don't need to update
updateStatus();
}
}
public boolean isInitialized() {
// Once initialization succeeds or fails, it never resets,
// so we don't need to update
updateStatus();
}
}
public boolean failedToInitialize() {
// Once initialization succeeds or fails, it never resets,
// so we don't need to update
updateStatus();
}
}
if (vm.canGet1_5LanguageFeatures()) {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
= jdwpFields[i];
}
} else {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
null,
}
}
}
return fields;
}
void addVisibleFields(List<Field> visibleList, Map<String, Field> visibleTable, List<String> ambiguousNames) {
} else {
// identical field from two branches; do nothing
}
}
}
}
/*
* Maintain two different collections of visible fields. The
* list maintains a reasonable order for return. The
* hash map provides an efficient way to lookup visible fields
* by name, important for finding hidden or ambiguous fields.
*/
/* Track fields removed from above collection due to ambiguity */
/* Add inherited, visible fields */
/*
* TO DO: Be defensive and check for cyclic interface inheritance
*/
}
/*
* Insert fields from this type, removing any inherited fields they
* hide.
*/
}
}
return retList;
}
/* Continue the recursion only if this type is new */
/* Add local fields */
/* Add inherited fields */
}
}
}
return fieldList;
}
Field f;
searchList = visibleFields();
return f;
}
}
//throw new NoSuchFieldException("Field '" + fieldName + "' not found in " + name());
return null;
}
if (!vm.canGet1_5LanguageFeatures()) {
methods = methods1_4();
} else {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
}
}
return methods;
}
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
null,
}
return methods;
}
/*
* Utility method used by subclasses to build lists of visible
* methods.
*/
}
/*
* Build a collection of all visible methods. The hash
* map allows us to do this efficiently by keying on the
* concatenation of name and signature.
*/
/*
* ... but the hash map destroys order. Methods should be
* returned in a sensible order, as they are in allMethods().
* So, start over with allMethods() and use the hash map
* to filter that ordered collection.
*/
return list;
}
}
}
return retList;
}
}
}
return retList;
}
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
/* The separator is historically '$' but could also be '#' */
if ( c =='$' || c== '#' ) {
}
}
}
return nested;
}
}
/*
* Field must be in this object's class, a superclass, or
* implemented interface
*/
if (!declType.isAssignableFrom(this)) {
throw new IllegalArgumentException("Invalid field");
}
}
throw new IllegalArgumentException("Cannot set value of final field");
}
}
/**
* Returns a map of field values
*/
for (int i=0; i<size; i++) {
// Do more validation specific to ReferenceType field getting
throw new IllegalArgumentException(
"Attempt to use non-static field with ReferenceType");
}
}
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
throw new InternalException(
"Wrong number of values returned from target VM");
}
for (int i=0; i<size; i++) {
}
return map;
}
if (classObject == null) {
// Are classObjects unique for an Object, or
// created each time? Is this spec'ed?
synchronized(this) {
if (classObject == null) {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
}
}
return classObject;
}
}
}
}
throws AbsentInformationException {
return result;
}
return stratum.sourceNames(this);
}
throws AbsentInformationException {
return result;
}
return stratum.sourcePaths(this);
}
// Does not need synchronization, since worst-case
// static info is fetched twice
try {
} catch (JDWPException exc) {
} else {
throw exc.toJDIException();
}
}
}
if (bsn == ABSENT_BASE_SOURCE_NAME) {
throw new AbsentInformationException();
}
return bsn;
}
}
return bsp;
}
if (baseSourceDir == null) {
int index = 0;
int nextIndex;
}
}
return baseSourceDir;
}
throws AbsentInformationException {
if (!vm.canGetSourceDebugExtension()) {
throw new UnsupportedOperationException();
}
if (sde == NO_SDE_INFO_MARK) {
throw new AbsentInformationException();
}
return sde.sourceDebugExtension;
}
if (!vm.canGetSourceDebugExtension()) {
return NO_SDE_INFO_MARK;
}
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
} else {
}
}
return sde;
}
return sde.availableStrata();
} else {
return strata;
}
}
/**
* Always returns non-null stratumID
*/
return sdei.defaultStratumId;
} else {
return SDE.BASE_STRATUM_NAME;
}
}
public int modifiers() {
if (modifiers == -1)
getModifiers();
return modifiers;
}
throws AbsentInformationException {
}
throws AbsentInformationException {
boolean someAbsent = false; // A method that should have info, didn't
try {
} catch(AbsentInformationException exc) {
someAbsent = true;
}
}
// If we retrieved no line info, and at least one of the methods
// should have had some (as determined by an
// AbsentInformationException being thrown) then we rethrow
// the AbsentInformationException.
throw new AbsentInformationException();
}
return list;
}
throws AbsentInformationException {
null,
}
int lineNumber)
throws AbsentInformationException {
// A method that should have info, didn't
boolean someAbsent = false;
// A method that should have info, did
boolean somePresent = false;
// eliminate native and abstract to eliminate
// false positives
if (!method.isAbstract() &&
try {
lineNumber));
somePresent = true;
} catch(AbsentInformationException exc) {
someAbsent = true;
}
}
}
if (someAbsent && !somePresent) {
throw new AbsentInformationException();
}
return list;
}
if (!vm.canGetInstanceInfo()) {
throw new UnsupportedOperationException(
"target does not support getting instances");
}
if (maxInstances < 0) {
throw new IllegalArgumentException("maxInstances is less than zero: "
+ maxInstances);
}
// JDWP can't currently handle more than this (in mustang)
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
private void getClassFileVersion() {
if (!vm.canGetClassFileVersion()) {
throw new UnsupportedOperationException();
}
if (versionNumberGotten) {
return;
} else {
try {
} catch (JDWPException exc) {
majorVersion = 0;
minorVersion = 0;
versionNumberGotten = true;
return;
} else {
throw exc.toJDIException();
}
}
versionNumberGotten = true;
}
}
public int majorVersion() {
try {
} catch (RuntimeException exc) {
throw exc;
}
return majorVersion;
}
public int minorVersion() {
try {
} catch (RuntimeException exc) {
throw exc;
}
return minorVersion;
}
private void getConstantPoolInfo() {
if (!vm.canGetConstantPool()) {
throw new UnsupportedOperationException();
}
if (constantPoolInfoGotten) {
return;
} else {
try {
} catch (JDWPException exc) {
constanPoolCount = 0;
constantPoolInfoGotten = true;
return;
} else {
throw exc.toJDIException();
}
}
byte[] cpbytes;
constantPoolInfoGotten = true;
}
}
public int constantPoolCount() {
try {
} catch (RuntimeException exc) {
throw exc;
}
return constanPoolCount;
}
public byte[] constantPool() {
try {
} catch (RuntimeException exc) {
throw exc;
}
if (constantPoolBytesRef != null) {
/*
* Arrays are always modifiable, so it is a little unsafe
* to return the cached bytecodes directly; instead, we
* make a clone at the cost of using more memory.
*/
} else {
return null;
}
}
// Does not need synchronization, since worst-case
// static info is fetched twice
void getModifiers() {
if (modifiers != -1) {
return;
}
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
isPrepared = true;
}
}
void updateStatus() {
try {
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
void markPrepared() {
isPrepared = true;
}
long ref() {
return ref;
}
// Make sure they're all here - the obsolete method
// won't be found and so will have index -1
}
// Make sure they're all here
}
/*
* Return true if an instance of this type
* can be assigned to a variable of the given type
*/
}
}
}
}
this.genericSignature = null;
} else{
this.genericSignature = signature;
}
this.genericSignatureGotten = true;
}
/*
* TO DO: Centralize JNI signature knowledge.
*
* Ref:
*/
boolean isPA;
if (i < 0) {
isPA = false;
} else {
isPA = (c != 'L');
}
return isPA;
}
/* OTI FIX: Must be a primitive type or the void type */
if (sig == 'V') {
} else {
}
} else {
// Must be a reference type.
) {
// Caller wants type of boot class field
} else {
// Caller wants type of non-boot class field
}
}
return type;
}
if (classLoader() != null) {
} else {
return "no class loader";
}
}
}