1 /*
   2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jdi;
  27 
  28 import java.util.List;
  29 import java.util.Map;
  30 
  31 /**
  32  * The type of an object in a target VM. ReferenceType encompasses
  33  * classes, interfaces, and array types as defined in
  34  * <cite>The Java&trade; Language Specification</cite>.
  35  * All ReferenceType objects belong to one of the following
  36  * subinterfaces:
  37  * {@link ClassType} for classes,
  38  * {@link InterfaceType} for interfaces, and
  39  * {@link ArrayType} for arrays.
  40  * Note that primitive classes (for example, the
  41  * {@link ClassObjectReference#reflectedType() reflected type} of
  42  * {@link java.lang.Integer#TYPE Integer.TYPE})
  43  * are represented as ClassType.
  44  * The VM creates Class objects for all three, so from the VM perspective,
  45  * each ReferenceType maps to a distinct Class object.
  46  * <p>
  47  * ReferenceTypes can
  48  * be obtained by querying a particular {@link ObjectReference} for its
  49  * type or by getting a list of all reference types from the
  50  * {@link VirtualMachine}.
  51  * <p>
  52  * ReferenceType provides access to static type information such as
  53  * methods and fields and provides access to dynamic type
  54  * information such as the corresponding Class object and the classloader.
  55  * <p>
  56  * Any method on <code>ReferenceType</code> which directly or
  57  * indirectly takes <code>ReferenceType</code> as an parameter may throw
  58  * {@link com.sun.jdi.VMDisconnectedException} if the target VM is
  59  * disconnected and the {@link com.sun.jdi.event.VMDisconnectEvent} has been or is
  60  * available to be read from the {@link com.sun.jdi.event.EventQueue}.
  61  * <p>
  62  * Any method on <code>ReferenceType</code> which directly or
  63  * indirectly takes <code>ReferenceType</code> as an parameter may throw
  64  * {@link com.sun.jdi.VMOutOfMemoryException} if the target VM has run out of memory.
  65  * <p>
  66  * Any method on <code>ReferenceType</code> or which directly or indirectly takes
  67  * <code>ReferenceType</code> as parameter may throw
  68  * {@link com.sun.jdi.ObjectCollectedException} if the mirrored type has been unloaded.
  69  *
  70  * @see ObjectReference
  71  * @see ObjectReference#referenceType
  72  * @see VirtualMachine
  73  * @see VirtualMachine#allClasses
  74  *
  75  * @author Robert Field
  76  * @author Gordon Hirsch
  77  * @author James McIlree
  78  * @since  1.3
  79  */
  80 @jdk.Exported
  81 public interface ReferenceType
  82     extends Type, Comparable<ReferenceType>, Accessible
  83 {
  84 
  85     /**
  86      * Gets the fully qualified name of this type. The returned name
  87      * is formatted as it might appear in a Java programming langauge
  88      * declaration for objects of this type.
  89      * <p>
  90      * For primitive classes
  91      * the returned name is the name of the corresponding primitive
  92      * type; for example, "int" is returned as the name of the class
  93      * represented by {@link java.lang.Integer#TYPE Integer.TYPE}.
  94      * @return a string containing the type name.
  95      */
  96     String name();
  97 
  98     /**
  99      * Gets the generic signature for this type if there is one.
 100      * Generic signatures are described in the
 101      * <cite>The Java&trade; Virtual Machine Specification</cite>.
 102      *
 103      * @return a string containing the generic signature, or <code>null</code>
 104      * if there is no generic signature.
 105      *
 106      * @since 1.5
 107      */
 108     String genericSignature();
 109 
 110     /**
 111      * Gets the classloader object which loaded the class corresponding
 112      * to this type.
 113      *
 114      * @return a {@link ClassLoaderReference} which mirrors the classloader,
 115      * or <code>null</code> if the class was loaded through the bootstrap class
 116      * loader.
 117      */
 118     ClassLoaderReference classLoader();
 119 
 120     /**
 121      * Gets the module object which contains the class corresponding
 122      * to this type.
 123      *
 124      * @return a {@link Module} which mirrors the module in the target VM.
 125      *
 126      * @throws java.lang.UnsupportedOperationException if
 127      * the target virtual machine does not support this
 128      * operation.
 129      * <UL>
 130      *
 131      * @since 1.9
 132      */
 133     Module module();
 134 
 135     /**
 136      * Gets an identifying name for the source corresponding to the
 137      * declaration of this type. Interpretation of this string is
 138      * the responsibility of the source repository mechanism.
 139      * <P>
 140      * The returned name is dependent on VM's default stratum
 141      * ({@link VirtualMachine#getDefaultStratum()}).
 142      * In the reference implementation, when using the base stratum,
 143      * the returned string is the
 144      * unqualified name of the source file containing the declaration
 145      * of this type.  In other strata the returned source name is
 146      * the first source name for that stratum.  Since other languages
 147      * may have more than one source name for a reference type,
 148      * the use of {@link Location#sourceName()} or
 149      * {@link #sourceNames(String)} is preferred.
 150      * <p>
 151      * For arrays ({@link ArrayType}) and primitive classes,
 152      * AbsentInformationException is always thrown.
 153      *
 154      * @return the string source file name
 155      * @throws AbsentInformationException if the source name is not
 156      * known
 157      */
 158     String sourceName() throws AbsentInformationException;
 159 
 160     /**
 161      * Gets the identifying names for all the source corresponding to the
 162      * declaration of this type. Interpretation of these names is
 163      * the responsibility of the source repository mechanism.
 164      * <P>
 165      * The returned names are for the specified stratum
 166      * (see {@link Location} for a description of strata).
 167      * In the reference implementation, when using the Java
 168      * programming language stratum,
 169      * the returned List contains one element: a String which is the
 170      * unqualified name of the source file containing the declaration
 171      * of this type.  In other strata the returned source names are
 172      * all the source names defined for that stratum.
 173      *
 174      * @param stratum The stratum to retrieve information from
 175      * or <code>null</code> for the declaring type's
 176      * default stratum.
 177      *
 178      * @return a List of String objects each representing a source name
 179      *
 180      * @throws AbsentInformationException if the source names are not
 181      * known.
 182      * <p>
 183      * For arrays ({@link ArrayType}) and primitive classes,
 184      * AbsentInformationException is always thrown.
 185      *
 186      * @since 1.4
 187      */
 188     List<String> sourceNames(String stratum) throws AbsentInformationException;
 189 
 190     /**
 191      * Gets the paths to the source corresponding to the
 192      * declaration of this type. Interpretation of these paths is
 193      * the responsibility of the source repository mechanism.
 194      * <P>
 195      * The returned paths are for the specified stratum
 196      * (see {@link Location} for a description of strata).
 197      * In the reference implementation, for strata which
 198      * do not explicitly specify source path (the Java
 199      * programming language stratum never does), the returned
 200      * strings are the {@link #sourceNames(String)} prefixed by
 201      * the package name of this ReferenceType
 202      * converted to a platform dependent path.
 203      * For example, on a Windows platform,
 204      * <CODE>java.lang.Thread</CODE>
 205      * would return a List containing one element:
 206      * <CODE>"java\lang\Thread.java"</CODE>.
 207      *
 208      * @param stratum The stratum to retrieve information from
 209      * or <code>null</code> for the declaring type's
 210      * default stratum.
 211      *
 212      * @return a List of String objects each representing a source path
 213      *
 214      * @throws AbsentInformationException if the source names are not
 215      * known.
 216      * <p>
 217      * For arrays ({@link ArrayType}) and primitive classes,
 218      * AbsentInformationException is always thrown.
 219      *
 220      * @since 1.4
 221      */
 222     List<String> sourcePaths(String stratum) throws AbsentInformationException;
 223 
 224     /**
 225      * Get the source debug extension of this type.
 226      * <p>
 227      * Not all target virtual machines support this operation.
 228      * Use
 229      * {@link VirtualMachine#canGetSourceDebugExtension() canGetSourceDebugExtension()}
 230      * to determine if the operation is supported.
 231      * @return as a string the source debug extension attribute
 232      * @throws AbsentInformationException if the extension is not
 233      * specified
 234      * @throws java.lang.UnsupportedOperationException if
 235      * the target virtual machine does not support this
 236      * operation - see
 237      * {@link VirtualMachine#canGetSourceDebugExtension() canGetSourceDebugExtension()},
 238      */
 239     String sourceDebugExtension() throws AbsentInformationException;
 240 
 241     /**
 242      * Determines if this type was declared static. Only nested types,
 243      * can be declared static, so <code>false</code> is returned
 244      * for any package-level type, array type, or primitive class.
 245      *
 246      * @return <code>true</code> if this type is static; false otherwise.
 247      */
 248     boolean isStatic();
 249 
 250     /**
 251      * Determines if this type was declared abstract.
 252      * <p>
 253      * For arrays ({@link ArrayType}) and primitive classes,
 254      * the return value is undefined.
 255      *
 256      * @return <code>true</code> if this type is abstract; false otherwise.
 257      */
 258     boolean isAbstract();
 259 
 260     /**
 261      * Determines if this type was declared final.
 262      * <p>
 263      * For arrays ({@link ArrayType}) and primitive classes,
 264      * the return value is always true.
 265      *
 266      * @return <code>true</code> if this type is final; false otherwise.
 267      */
 268     boolean isFinal();
 269 
 270     /**
 271      * Determines if this type has been prepared. See the JVM
 272      * specification for a definition of class preparation.
 273      * <p>
 274      * For arrays ({@link ArrayType}) and primitive classes,
 275      * the return value is undefined.
 276      *
 277      * @return <code>true</code> if this type is prepared; false otherwise.
 278      */
 279     boolean isPrepared();
 280 
 281     /**
 282      * Determines if this type has been verified. See the JVM
 283      * specification for a definition of class verification.
 284      * <p>
 285      * For arrays ({@link ArrayType}) and primitive classes,
 286      * the return value is undefined.
 287      *
 288      * @return <code>true</code> if this type is verified; false otherwise.
 289      */
 290     boolean isVerified();
 291 
 292     /**
 293      * Determines if this type has been initialized. See the JVM
 294      * specification for a definition of class verification.
 295      * For {@link InterfaceType}, this method always returns the
 296      * same value as {@link #isPrepared()}.
 297      * <p>
 298      * For arrays ({@link ArrayType}) and primitive classes,
 299      * the return value is undefined.
 300      *
 301      * @return <code>true</code> if this type is initialized; false otherwise.
 302      */
 303     boolean isInitialized();
 304 
 305     /**
 306      * Determines if initialization failed for this class. See the JVM
 307      * specification for details on class initialization.
 308      * <p>
 309      * For arrays ({@link ArrayType}) and primitive classes,
 310      * the return value is undefined.
 311      *
 312      * @return <code>true</code> if initialization was attempted and
 313      * failed; false otherwise.
 314      */
 315     boolean failedToInitialize();
 316 
 317     /**
 318      * Returns a list containing each {@link Field} declared in this type.
 319      * Inherited fields are not included. Any synthetic fields created
 320      * by the compiler are included in the list.
 321      * <p>
 322      * For arrays ({@link ArrayType}) and primitive classes, the returned
 323      * list is always empty.
 324      *
 325      * @return a list {@link Field} objects; the list has length 0
 326      * if no fields exist.
 327      * @throws ClassNotPreparedException if this class not yet been
 328      * prepared.
 329      */
 330     List<Field> fields();
 331 
 332     /**
 333      * Returns a list containing each unhidden and unambiguous {@link Field}
 334      * in this type.
 335      * Each field that can be accessed from the class
 336      * or its instances with its simple name is included. Fields that
 337      * are ambiguously multiply inherited or fields that are hidden by
 338      * fields with the same name in a more recently inherited class
 339      * cannot be accessed
 340      * by their simple names and are not included in the returned
 341      * list. All other inherited fields are included.
 342      * See JLS section 8.3 for details.
 343      * <p>
 344      * For arrays ({@link ArrayType}) and primitive classes, the returned
 345      * list is always empty.
 346      *
 347      * @return a List of {@link Field} objects; the list has length
 348      * 0 if no visible fields exist.
 349      * @throws ClassNotPreparedException if this class not yet been
 350      * prepared.
 351      */
 352     List<Field> visibleFields();
 353 
 354     /**
 355      * Returns a list containing each {@link Field} declared in this type,
 356      * and its superclasses, implemented interfaces, and/or superinterfaces.
 357      * All declared and inherited
 358      * fields are included, regardless of whether they are hidden or
 359      * multiply inherited.
 360      * <p>
 361      * For arrays ({@link ArrayType}) and primitive classes, the returned
 362      * list is always empty.
 363      *
 364      * @return a List of {@link Field} objects; the list has length
 365      * 0 if no fields exist.
 366      * @throws ClassNotPreparedException if this class not yet been
 367      * prepared.
 368      */
 369     List<Field> allFields();
 370 
 371     /**
 372      * Finds the visible {@link Field} with the given
 373      * non-ambiguous name. This method follows the
 374      * inheritance rules specified in the JLS (8.3.3) to determine
 375      * visibility.
 376      * <p>
 377      * For arrays ({@link ArrayType}) and primitive classes, the returned
 378      * value is always null.
 379      *
 380      * @param fieldName a String containing the name of desired field.
 381      * @return a {@link Field} object which mirrors the found field, or
 382      * null if there is no field with the given name or if the given
 383      * name is ambiguous.
 384      * @throws ClassNotPreparedException if this class not yet been
 385      * prepared.
 386      */
 387     Field fieldByName(String fieldName);
 388 
 389     /**
 390      * Returns a list containing each {@link Method} declared
 391      * directly in this type.
 392      * Inherited methods are not included. Constructors,
 393      * the initialization method if any, and any synthetic methods created
 394      * by the compiler are included in the list.
 395      * <p>
 396      * For arrays ({@link ArrayType}) and primitive classes, the returned
 397      * list is always empty.
 398      *
 399      * @return a list {@link Method} objects; the list has length 0
 400      * if no methods exist.
 401      * @throws ClassNotPreparedException if this class not yet been
 402      * prepared.
 403      */
 404     List<Method> methods();
 405 
 406     /**
 407      * Returns a list containing each {@link Method}
 408      * declared or inherited by this type. Methods from superclasses
 409      * or superinterfaces that that have been hidden or overridden
 410      * are not included.
 411      * <p>
 412      * Note that despite this exclusion, multiple inherited methods
 413      * with the same signature can be present in the returned list, but
 414      * at most one can be a member of a {@link ClassType}.
 415      * See JLS section 8.4.6 for details.
 416      * <p>
 417      * For arrays ({@link ArrayType}) and primitive classes, the returned
 418      * list is always empty.
 419      *
 420      * @return a List of {@link Method} objects; the list has length
 421      * 0 if no visible methods exist.
 422      * @throws ClassNotPreparedException if this class not yet been
 423      * prepared.
 424      */
 425     List<Method> visibleMethods();
 426 
 427     /**
 428      * Returns a list containing each {@link Method} declared in this type,
 429      * and its superclasses, implemented interfaces, and/or superinterfaces.
 430      * All declared and inherited
 431      * methods are included, regardless of whether they are hidden or
 432      * overridden.
 433      * <p>
 434      * For arrays ({@link ArrayType}) and primitive classes, the returned
 435      * list is always empty.
 436      *
 437      * @return a List of {@link Method} objects; the list has length
 438      * 0 if no methods exist.
 439      * @throws ClassNotPreparedException if this class not yet been
 440      * prepared.
 441      */
 442     List<Method> allMethods();
 443 
 444     /**
 445      * Returns a List containing each visible {@link Method} that
 446      * has the given name.  This is most commonly used to
 447      * find overloaded methods.
 448      * <p>
 449      * Overridden and hidden methods are not included.
 450      * See JLS (8.4.6) for details.
 451      * <p>
 452      * For arrays ({@link ArrayType}) and primitive classes, the returned
 453      * list is always empty.
 454      *
 455      * @param name the name of the method to find.
 456      * @return a List of {@link Method} objects that match the given
 457      * name; the list has length 0 if no matching methods are found.
 458      * @throws ClassNotPreparedException if this class not yet been
 459      * prepared.
 460      */
 461     List<Method> methodsByName(String name);
 462 
 463     /**
 464      * Returns a List containing each visible {@link Method} that
 465      * has the given name and signature.
 466      * The signature string is the
 467      * JNI signature for the target method:
 468      * <ul>
 469      * <li><code>()V</code>
 470      * <li><code>([Ljava/lang/String;)V</code>
 471      * <li><code>(IIII)Z</code>
 472      * </ul>
 473      * This method follows the inheritance rules specified
 474      * in the JLS (8.4.6) to determine visibility.
 475      * <p>
 476      * At most one method in the list is a concrete method and a
 477      * component of {@link ClassType}; any other methods in the list
 478      * are abstract. Use {@link ClassType#concreteMethodByName} to
 479      * retrieve only the matching concrete method.
 480      * <p>
 481      * For arrays ({@link ArrayType}) and primitive classes, the returned
 482      * list is always empty.
 483      *
 484      * @param name the name of the method to find.
 485      * @param signature the signature of the method to find
 486      * @return a List of {@link Method} objects that match the given
 487      * name and signature; the list has length 0 if no matching methods
 488      * are found.
 489      * @throws ClassNotPreparedException if this class not yet been
 490      * prepared.
 491      */
 492     List<Method> methodsByName(String name, String signature);
 493 
 494     /**
 495      * Returns a List containing {@link ReferenceType} objects that are
 496      * declared within this type and are currently loaded into the Virtual
 497      * Machine.  Both static nested types and non-static nested
 498      * types (that is, inner types) are included. Local inner types
 499      * (declared within a code block somewhere in this reference type) are
 500      * also included in the returned list.
 501      * <p>
 502      * For arrays ({@link ArrayType}) and primitive classes, the returned
 503      * list is always empty.
 504      *
 505      * @return a List of nested {@link ReferenceType} objects; the list
 506      * has 0 length if there are no nested types.
 507      */
 508     List<ReferenceType> nestedTypes();
 509 
 510     /**
 511      * Gets the {@link Value} of a given static {@link Field} in this type.
 512      * The Field must be valid for this type;
 513      * that is, it must be declared in this type, a superclass, a
 514      * superinterface, or an implemented interface.
 515      *
 516      * @param field the field containing the requested value
 517      * @return the {@link Value} of the instance field.
 518      * @throws java.lang.IllegalArgumentException if the field is not valid for
 519      * this object's class.
 520      */
 521     Value getValue(Field field);
 522 
 523     /**
 524      * Returns a map containing the {@link Value} of each
 525      * static {@link Field} in the given list.
 526      * The Fields must be valid for this type;
 527      * that is, they must be declared in this type, a superclass, a
 528      * superinterface, or an implemented interface.
 529      *
 530      * @param fields a list of {@link Field} objects containing the
 531      * requested values.
 532      * @return a Map of the requested {@link Field} objects with
 533      * their {@link Value}.
 534      * @throws java.lang.IllegalArgumentException if any field is not valid for
 535      * this object's class.
 536      * @throws VMMismatchException if a {@link Mirror} argument and this mirror
 537      * do not belong to the same {@link VirtualMachine}.
 538      */
 539     Map<Field,Value> getValues(List<? extends Field> fields);
 540 
 541     /**
 542      * Returns the class object that corresponds to this type in the
 543      * target VM. The VM creates class objects for every kind of
 544      * ReferenceType: classes, interfaces, and array types.
 545      * @return the {@link ClassObjectReference} for this reference type
 546      * in the target VM.
 547      */
 548     ClassObjectReference classObject();
 549 
 550     /**
 551      * Returns a list containing a {@link Location} object
 552      * for each executable source line in this reference type.
 553      * <P>
 554      * This method is equivalent to
 555      * <code>allLineLocations(vm.getDefaultStratum(),null)</code> -
 556      * see {@link #allLineLocations(String,String)}
 557      * for more information.
 558      *
 559      * @throws AbsentInformationException if there is no line
 560      * number information for this class and there are non-native,
 561      * non-abstract executable members of this class.
 562      *
 563      * @throws ClassNotPreparedException if this class not yet
 564      * been prepared.
 565      */
 566     List<Location> allLineLocations() throws AbsentInformationException;
 567 
 568     /**
 569      * Returns a list containing a {@link Location} object
 570      * for each executable source line in this reference type.
 571      * Each location maps a source line to a range of code
 572      * indices.
 573      * The beginning of the range can be determined through
 574      * {@link Location#codeIndex}.  The returned list may contain
 575      * multiple locations for a particular line number, if the
 576      * compiler and/or VM has mapped that line to two or more
 577      * disjoint code index ranges.  Note that it is possible for
 578      * the same source line to represent different code index
 579      * ranges in <i>different</i> methods.
 580      * <P>
 581      * For arrays ({@link ArrayType}) and primitive classes, the
 582      * returned list is always empty.  For interfaces ({@link
 583      * InterfaceType}), the returned list will be non-empty only
 584      * if the interface has executable code in its class
 585      * initialization.
 586      * <P>
 587      * Returned list is for the specified <i>stratum</i>
 588      * (see {@link Location} for a description of strata).
 589      *
 590      * @param stratum The stratum to retrieve information from
 591      * or <code>null</code> for the {@link #defaultStratum()}.
 592      *
 593      * @param sourceName Return locations only within this
 594      * source file or <code>null</code> to return locations.
 595      *
 596      * @return a List of all source line {@link Location} objects.
 597      *
 598      * @throws AbsentInformationException if there is no line
 599      * number information for this class and there are non-native,
 600      * non-abstract executable members of this class.
 601      * Or if <i>sourceName</i> is non-<code>null</code>
 602      * and source name information is not present.
 603      *
 604      * @throws ClassNotPreparedException if this class not yet
 605      * been prepared.
 606      *
 607      * @since 1.4
 608      */
 609     List<Location> allLineLocations(String stratum, String sourceName)
 610                              throws AbsentInformationException;
 611 
 612     /**
 613      * Returns a List containing all {@link Location} objects
 614      * that map to the given line number.
 615      * <P>
 616      * This method is equivalent to
 617      * <code>locationsOfLine(vm.getDefaultStratum(), null,
 618      * lineNumber)</code> -
 619      * see {@link
 620      * #locationsOfLine(java.lang.String,java.lang.String,int)}
 621      * for more information.
 622      *
 623      * @param lineNumber the line number
 624      *
 625      * @return a List of all {@link Location} objects that map to
 626      * the given line.
 627      *
 628      * @throws AbsentInformationException if there is no line
 629      * number information for this class.
 630      *
 631      * @throws ClassNotPreparedException if this class not yet
 632      * been prepared.
 633      *
 634      * @see VirtualMachine#getDefaultStratum()
 635      */
 636     List<Location> locationsOfLine(int lineNumber)
 637         throws AbsentInformationException;
 638 
 639     /**
 640      * Returns a List containing all {@link Location} objects
 641      * that map to the given line number.
 642      * <P>
 643      * For arrays ({@link ArrayType}) and primitive classes, the
 644      * returned list is always empty.
 645      * For interfaces ({@link InterfaceType}), the returned list
 646      * will be non-empty only if the interface has executable code
 647      * in its class initialization at the specified line number.
 648      * An empty list will be returned if there is no executable
 649      * code at the specified line number.
 650      * <p>
 651      * Returned list is for the specified <i>stratum</i>
 652      * (see {@link Location} for a description of strata).
 653      *
 654      * @param stratum the stratum to use for comparing line number
 655      *                and source name, or <code>null</code> to
 656      *                use the {@link #defaultStratum()}.
 657      *
 658      * @param sourceName the source name containing the line
 659      *                   number, or <code>null</code> to match
 660      *                   all source names
 661      *
 662      * @param lineNumber the line number
 663      *
 664      * @return a List of all {@link Location} objects that map
 665      *         to the given line.
 666      *
 667      * @throws AbsentInformationException if there is no line
 668      *         number information for this class.
 669      *         Or if <i>sourceName</i> is non-<code>null</code>
 670      *         and source name information is not present.
 671      *
 672      * @throws ClassNotPreparedException if this class not yet
 673      *         been prepared.
 674      *
 675      * @since 1.4
 676      */
 677     List<Location> locationsOfLine(String stratum,
 678                                    String sourceName,
 679                                    int lineNumber)
 680                      throws AbsentInformationException;
 681 
 682     /**
 683      * Return the available strata for this reference type.
 684      * <P>
 685      * See the {@link Location} for a description of strata.
 686      *
 687      * @return List of <CODE>java.lang.String</CODE>, each
 688      * representing a stratum
 689      *
 690      * @since 1.4
 691      */
 692     List<String> availableStrata();
 693 
 694     /**
 695      * Returns the default stratum for this reference type.
 696      * This value is specified in the class file and cannot
 697      * be set by the user.  If the class file does not
 698      * specify a default stratum the base stratum
 699      * (<code>"Java"</code>) will be returned.
 700      * <P>
 701      * See the {@link Location} for a description of strata.
 702      *
 703      * @since 1.4
 704      */
 705     String defaultStratum();
 706 
 707     /**
 708      * Returns instances of this ReferenceType.
 709      * Only instances that are reachable for the purposes of garbage collection
 710      * are returned.
 711      * <p>
 712      * Not all target virtual machines support this operation.
 713      * Use {@link VirtualMachine#canGetInstanceInfo()}
 714      * to determine if the operation is supported.
 715      *
 716      * @see VirtualMachine#instanceCounts(List)
 717      * @see ObjectReference#referringObjects(long)
 718      *
 719      * @param maxInstances the maximum number of instances to return.
 720      *        Must be non-negative.  If zero, all instances are returned.
 721      * @return a List of {@link ObjectReference} objects.  If there are
 722      * no instances of this ReferenceType, a zero-length list is returned.
 723      *
 724      * @throws java.lang.UnsupportedOperationException if
 725      * the target virtual machine does not support this
 726      * operation - see
 727      * {@link VirtualMachine#canGetInstanceInfo() canGetInstanceInfo()}
 728      * @throws java.lang.IllegalArgumentException if maxInstances is less
 729      *         than zero.
 730      * @since 1.6
 731      */
 732     List<ObjectReference> instances(long maxInstances);
 733 
 734     /**
 735      * Compares the specified Object with this ReferenceType for equality.
 736      *
 737      * @return  true if the Object is a {@link ReferenceType}, if the
 738      * ReferenceTypes belong to the same VM, and if they mirror classes
 739      * which correspond to the same instance of java.lang.Class in that VM.
 740      */
 741     boolean equals(Object obj);
 742 
 743     /**
 744      * Returns the hash code value for this ObjectReference.
 745      *
 746      * @return the integer hash code
 747      */
 748     int hashCode();
 749 
 750     /**
 751      * Returns the class major version number, as defined in the class file format
 752      * of the Java Virtual Machine Specification.
 753      *
 754      * For arrays ({@link ArrayType}) and primitive classes,
 755      * the returned major version number value is zero.
 756      *
 757      * Not all target virtual machines support this operation.
 758      * Use {@link VirtualMachine#canGetClassFileVersion()}
 759      * to determine if the operation is supported.
 760      *
 761      * @return the major version number of the class.
 762      *
 763      * @throws java.lang.UnsupportedOperationException if
 764      * the target virtual machine does not support this
 765      * operation - see
 766      * {@link VirtualMachine#canGetClassFileVersion() canGetClassFileVersion()}
 767      *
 768      * @since 1.6
 769      */
 770     int majorVersion();
 771 
 772 
 773     /**
 774      * Returns the class minor version number, as defined in the class file format
 775      * of the Java Virtual Machine Specification.
 776      *
 777      * For arrays ({@link ArrayType}) and primitive classes,
 778      * the returned minor version number value is zero.
 779      *
 780      * Not all target virtual machines support this operation.
 781      * Use {@link VirtualMachine#canGetClassFileVersion()}
 782      * to determine if the operation is supported.
 783      *
 784      * @return the minor version number of the class.
 785      *
 786      * @throws java.lang.UnsupportedOperationException if
 787      * the target virtual machine does not support this
 788      * operation - see
 789      * {@link VirtualMachine#canGetClassFileVersion() canGetClassFileVersion()}
 790      *
 791      * @since 1.6
 792      */
 793     int minorVersion();
 794 
 795     /**
 796      * Returns the number of entries in the constant pool plus one.
 797      * This corresponds to the constant_pool_count item of the Class File Format
 798      * in the Java Virtual Machine Specification.
 799      *
 800      * For arrays ({@link ArrayType}) and primitive classes,
 801      * the returned constant pool count value is zero.
 802      *
 803      * Not all target virtual machines support this operation.
 804      * Use {@link VirtualMachine#canGetConstantPool()}
 805      * to determine if the operation is supported.
 806      *
 807      * @return total number of constant pool entries for a class plus one.
 808      *
 809      * @throws java.lang.UnsupportedOperationException if
 810      * the target virtual machine does not support this
 811      * operation - see
 812      * {@link VirtualMachine#canGetConstantPool() canGetConstantPool()}
 813      *
 814      * @see #constantPool()
 815      * @since 1.6
 816      */
 817     int constantPoolCount();
 818 
 819     /**
 820      * Returns the raw bytes of the constant pool in the format of the
 821      * constant_pool item of the Class File Format in the Java Virtual
 822      * Machine Specification. The format of the constant pool may
 823      * differ between versions of the Class File Format, so, the
 824      * minor and major class version numbers should be checked for
 825      * compatibility.
 826      *
 827      * For arrays ({@link ArrayType}) and primitive classes,
 828      * a zero length byte array is returned.
 829      *
 830      * Not all target virtual machines support this operation.
 831      * Use {@link VirtualMachine#canGetConstantPool()}
 832      * to determine if the operation is supported.
 833      *
 834      * @return the raw bytes of constant pool.
 835      *
 836      * @throws java.lang.UnsupportedOperationException if
 837      * the target virtual machine does not support this
 838      * operation - see
 839      * {@link VirtualMachine#canGetConstantPool() canGetConstantPool()}
 840      *
 841      * @see #constantPoolCount()
 842      * @since 1.6
 843      */
 844      byte[] constantPool();
 845 
 846 }