1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.jdi.hcr; 12 13 14 /** 15 * Hot code replacement extension to <code>com.sun.jdi.ReferenceType</code>. 16 */ 17 public interface ReferenceType { 18 /** 19 * An HCR-eligible class file may now be loaded and reloaded at some later point(s). 20 * Methods on the stack may come from any of several versions of the same HCR-eligible class. 21 * The debugger can query any class file related object (class, method, or field) for 22 * information about the version of the class file from which it came. 23 * <p> 24 * Classes loaded by a cooperating class loader are flagged as HCR-eligible for hot code 25 * replacement. 26 * <p> 27 * Class file versions are identified by the CRC-32 of the entire class file contents. 28 * <p> 29 * The VM typically computes and remembers the CRC when it digests a class file. Note 30 * this behavior is optional; VM need not retain any CRCs. 31 * A debugger can query any class for its class CRC and eligibility: 32 * <ul> 33 * <li>The query can be made at at time. 34 * <li>This is not directed to any specific thread. 35 * <li>Threads may be running at the time; they are not stopped. 36 * <li>Other JDI-level operations may be in progress. 37 * <li>If a debugger knows only about a method or a field, it must first query its defining 38 * class first to find out what is the CRC for this method or field. 39 * </ul> 40 * All information returned does not change over the lifetime of the reference type object 41 * (replacing the class results in a new reference type object). This info can therefore be 42 * cached client-side with impunity. 43 * <p> 44 * This simple mechanism allows the IDE to detect that an object does not belong to the current 45 * class file base (debugger computes CRC of current class file and queries VM and compares to 46 * its CRC). It also allows the debugger to quickly detect whether two objects come from 47 * the same class file (debugger queries VM and compares CRCs). By checking the HCR-eligibility 48 * bit, the debugger can determine whether the class could be hot replaced in principle. 49 * <p> 50 * Returns the CRC-32 of the entire class file contents for this reference type. 51 * 52 * @see org.eclipse.jdi.hcr.VirtualMachine#classesHaveChanged 53 */ 54 public int getClassFileVersion(); 55 56 /** 57 * Returns whether this reference type is eligible for hot code replacement. 58 * 59 * @see org.eclipse.jdi.hcr.ReferenceType#getClassFileVersion 60 */ 61 public boolean isHCREligible(); 62 63 /** 64 * Returns whether this reference type knows its class file version. 65 * Returns false for <code>ArrayType</code>s. 66 */ 67 public boolean isVersionKnown(); 68 } 69