Lombok - v0.11.0

lombok.bytecode
Class ClassFileMetaData

java.lang.Object
  extended by lombok.bytecode.ClassFileMetaData

public class ClassFileMetaData
extends Object

Utility to read the constant pool, header, and inheritance information of any class file.


Constructor Summary
ClassFileMetaData(byte[] byteCode)
           
 
Method Summary
 boolean containsDouble(double value)
          Checks if the constant pool contains the provided double constant, which implies the constant is used somewhere in the code.
 boolean containsFloat(float value)
          Checks if the constant pool contains the provided float constant, which implies the constant is used somewhere in the code.
 boolean containsInteger(int value)
          Checks if the constant pool contains the provided int constant, which implies the constant is used somewhere in the code.
 boolean containsLong(long value)
          Checks if the constant pool contains the provided long constant, which implies the constant is used somewhere in the code.
 boolean containsStringConstant(String value)
          Checks if the constant pool contains the provided string constant, which implies the constant is used somewhere in the code.
 boolean containsUtf8(String value)
          Checks if the constant pool contains the provided 'raw' string.
 String getClassName()
          Returns the name of the class in JVM format, such as java/lang/String
 List<String> getInterfaces()
          Returns the name of all implemented interfaces.
 String getSuperClassName()
          Returns the name of the superclass in JVM format, such as java/lang/Object NB: If you try this on Object itself, you'll get null.
NB2: For interfaces and annotation interfaces, you'll always get java/lang/Object
 String poolContent()
          A toString() like utility to dump all contents of the constant pool into a string.
 boolean usesClass(String className)
          Checks if the constant pool contains a reference to the provided class.
 boolean usesField(String className, String fieldName)
          Checks if the constant pool contains a reference to a given field, either for writing or reading.
 boolean usesMethod(String className, String methodName)
          Checks if the constant pool contains a reference to a given method, with any signature (return type and parameter types).
 boolean usesMethod(String className, String methodName, String descriptor)
          Checks if the constant pool contains a reference to a given method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFileMetaData

public ClassFileMetaData(byte[] byteCode)
Method Detail

containsUtf8

public boolean containsUtf8(String value)
Checks if the constant pool contains the provided 'raw' string. These are used as source material for further JVM types, such as string constants, type references, etcetera.


usesClass

public boolean usesClass(String className)
Checks if the constant pool contains a reference to the provided class. NB: Most uses of a type do NOT show up as a class in the constant pool. For example, the parameter types and return type of any method you invoke or declare, are stored as signatures and not as type references, but the type to which any method you invoke belongs, is. Read the JVM Specification for more information.

Parameters:
className - must be provided JVM-style, such as java/lang/String

usesField

public boolean usesField(String className,
                         String fieldName)
Checks if the constant pool contains a reference to a given field, either for writing or reading.

Parameters:
className - must be provided JVM-style, such as java/lang/String

usesMethod

public boolean usesMethod(String className,
                          String methodName)
Checks if the constant pool contains a reference to a given method, with any signature (return type and parameter types).

Parameters:
className - must be provided JVM-style, such as java/lang/String

usesMethod

public boolean usesMethod(String className,
                          String methodName,
                          String descriptor)
Checks if the constant pool contains a reference to a given method.

Parameters:
className - must be provided JVM-style, such as java/lang/String
descriptor - must be provided JVM-style, such as (IZ)Ljava/lang/String;

containsStringConstant

public boolean containsStringConstant(String value)
Checks if the constant pool contains the provided string constant, which implies the constant is used somewhere in the code. NB: String literals get concatenated by the compiler. NB2: This method does NOT do any kind of normalization.


containsLong

public boolean containsLong(long value)
Checks if the constant pool contains the provided long constant, which implies the constant is used somewhere in the code. NB: compile-time constant expressions are evaluated at compile time.


containsDouble

public boolean containsDouble(double value)
Checks if the constant pool contains the provided double constant, which implies the constant is used somewhere in the code. NB: compile-time constant expressions are evaluated at compile time.


containsInteger

public boolean containsInteger(int value)
Checks if the constant pool contains the provided int constant, which implies the constant is used somewhere in the code. NB: compile-time constant expressions are evaluated at compile time.


containsFloat

public boolean containsFloat(float value)
Checks if the constant pool contains the provided float constant, which implies the constant is used somewhere in the code. NB: compile-time constant expressions are evaluated at compile time.


getClassName

public String getClassName()
Returns the name of the class in JVM format, such as java/lang/String


getSuperClassName

public String getSuperClassName()
Returns the name of the superclass in JVM format, such as java/lang/Object NB: If you try this on Object itself, you'll get null.
NB2: For interfaces and annotation interfaces, you'll always get java/lang/Object


getInterfaces

public List<String> getInterfaces()
Returns the name of all implemented interfaces.


poolContent

public String poolContent()
A toString() like utility to dump all contents of the constant pool into a string. NB: No guarantees are made about the exact layout of this string. It is for informational purposes only, don't try to parse it.
NB2: After a double or long, there's a JVM spec-mandated gap, which is listed as (cont.) in the returned string.


Lombok - v0.11.0

Copyright © 2009-2011 The Project Lombok Authors, licensed under the MIT licence.