aQute.lib.osgi
Class Clazz

java.lang.Object
  extended by aQute.lib.osgi.Clazz

public class Clazz
extends Object


Nested Class Summary
protected static class Clazz.Assoc
           
 class Clazz.ClassConstant
           
static class Clazz.FieldDef
           
static class Clazz.JAVA
           
static class Clazz.MethodDef
           
static class Clazz.QUERY
           
 
Field Summary
static EnumSet<Clazz.QUERY> HAS_ARGUMENT
           
 
Constructor Summary
Clazz(String path, Resource resource)
           
 
Method Summary
protected  void constantClass(DataInputStream in, int poolIndex)
           
protected  void constantDouble(DataInputStream in, int poolIndex)
           
protected  void constantLong(DataInputStream in, int poolIndex)
           
protected  void constantUtf8(DataInputStream in, int poolIndex)
           
protected  void crawl(byte[] code)
          We must find Class.forName references ...
static String fqnToBinary(String dotted)
           
static String fqnToPath(String dotted)
           
 Clazz.JAVA getFormat()
           
 String getFQN()
           
static void getImplementedPackages(Set<String> implemented, Analyzer analyzer, Clazz clazz)
           
static String getPackage(String clazz)
           
 String getPath()
           
 Set<String> getReferred()
           
static String getShortName(String cname)
           
 String getSourceFile()
           
static String internalToFqn(String string)
           
 boolean is(Clazz.QUERY query, Instruction instr, Analyzer analyzer)
           
 boolean isEnum()
           
 boolean isPublic()
           
protected  void nameAndType(DataInputStream in, int poolIndex, byte tag)
           
static String objectDescriptorToFQN(String string)
           
 Set<String> parseClassFile()
           
 Set<String> parseClassFile(InputStream in)
           
 Set<String> parseClassFile(InputStream in, ClassDataCollector cd)
           
 Set<String> parseClassFileWithCollector(ClassDataCollector cd)
           
 void parseDescriptor(String descriptor)
          This method parses a descriptor and adds the package of the descriptor to the referenced packages.
static String pathToFqn(String path)
           
protected  void pool(Object[] pool, int[] intPool)
           
 void reset()
          .class construct for different compilers sun 1.1 Detect static variable class$com$acme$MyClass 1.2 " 1.3 " 1.4 " 1.5 ldc_w (class) 1.6 " eclipse 1.1 class$0, ldc (string), invokestatic Class.forName 1.2 " 1.3 " 1.5 ldc (class) 1.6 " 1.5 and later is not an issue, sun pre 1.5 is easy to detect the static variable that decodes the class name.
static String toDescriptor(Class<?> clazz)
           
 String toString()
           
static String unCamel(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HAS_ARGUMENT

public static EnumSet<Clazz.QUERY> HAS_ARGUMENT
Constructor Detail

Clazz

public Clazz(String path,
             Resource resource)
Method Detail

parseClassFile

public Set<String> parseClassFile()
                           throws Exception
Throws:
Exception

parseClassFile

public Set<String> parseClassFile(InputStream in)
                           throws IOException
Throws:
IOException

parseClassFileWithCollector

public Set<String> parseClassFileWithCollector(ClassDataCollector cd)
                                        throws Exception
Throws:
Exception

parseClassFile

public Set<String> parseClassFile(InputStream in,
                                  ClassDataCollector cd)
                           throws IOException
Throws:
IOException

pool

protected void pool(Object[] pool,
                    int[] intPool)

nameAndType

protected void nameAndType(DataInputStream in,
                           int poolIndex,
                           byte tag)
                    throws IOException
Parameters:
in -
poolIndex -
tag -
Throws:
IOException

constantClass

protected void constantClass(DataInputStream in,
                             int poolIndex)
                      throws IOException
Parameters:
in -
poolIndex -
Throws:
IOException

constantDouble

protected void constantDouble(DataInputStream in,
                              int poolIndex)
                       throws IOException
Parameters:
in -
Throws:
IOException

constantLong

protected void constantLong(DataInputStream in,
                            int poolIndex)
                     throws IOException
Parameters:
in -
Throws:
IOException

constantUtf8

protected void constantUtf8(DataInputStream in,
                            int poolIndex)
                     throws IOException
Parameters:
in -
poolIndex -
Throws:
IOException

crawl

protected void crawl(byte[] code)
We must find Class.forName references ...

Parameters:
code -

parseDescriptor

public void parseDescriptor(String descriptor)
This method parses a descriptor and adds the package of the descriptor to the referenced packages. The syntax of the descriptor is:
   descriptor ::= ( '(' reference * ')' )? reference
   reference  ::= 'L' classname ( '<' references '>' )? ';' | 'B' | 'Z' | ... | '+' | '-' | '['
 
This methods uses heavy recursion to parse the descriptor and a roving pointer to limit the creation of string objects.

Parameters:
descriptor - The to be parsed descriptor
rover - The pointer to start at

getPackage

public static String getPackage(String clazz)

getReferred

public Set<String> getReferred()

getPath

public String getPath()

getSourceFile

public String getSourceFile()

reset

public void reset()
.class construct for different compilers sun 1.1 Detect static variable class$com$acme$MyClass 1.2 " 1.3 " 1.4 " 1.5 ldc_w (class) 1.6 " eclipse 1.1 class$0, ldc (string), invokestatic Class.forName 1.2 " 1.3 " 1.5 ldc (class) 1.6 " 1.5 and later is not an issue, sun pre 1.5 is easy to detect the static variable that decodes the class name. For eclipse, the class$0 gives away we have a reference encoded in a string. compilerversions/compilerversions.jar contains test versions of all versions/compilers.


is

public boolean is(Clazz.QUERY query,
                  Instruction instr,
                  Analyzer analyzer)
           throws Exception
Throws:
Exception

toString

public String toString()
Overrides:
toString in class Object

getFQN

public String getFQN()

getImplementedPackages

public static void getImplementedPackages(Set<String> implemented,
                                          Analyzer analyzer,
                                          Clazz clazz)
                                   throws Exception
Throws:
Exception

toDescriptor

public static String toDescriptor(Class<?> clazz)

getShortName

public static String getShortName(String cname)

fqnToPath

public static String fqnToPath(String dotted)

fqnToBinary

public static String fqnToBinary(String dotted)

pathToFqn

public static String pathToFqn(String path)

isPublic

public boolean isPublic()

isEnum

public boolean isEnum()

getFormat

public Clazz.JAVA getFormat()

objectDescriptorToFQN

public static String objectDescriptorToFQN(String string)

internalToFqn

public static String internalToFqn(String string)

unCamel

public static String unCamel(String id)


Copyright © 2012 aQute SARL. All Rights Reserved.