Search in sources :

Example 1 with JCJavaClassLoader

use of com.ibm.dtfj.java.javacore.JCJavaClassLoader in project openj9 by eclipse.

the class JavaRuntimeBuilder method addClassLoader.

/**
 * Must pass a valid class loader ID in order to generate a class loader object. Else exception
 * is thrown.
 *
 * @param classLoaderName optional
 * @param clID required, or else exception is throw and class loader is not created.
 * @param objectID optional (although generally this is the same as the clID for most javacores)
 * @return successfully created JavaClassLoader
 * @throws BuilderFailureException if class loader ID is invalid.
 */
public JavaClassLoader addClassLoader(String classLoaderName, long clID, long objectID) throws BuilderFailureException {
    try {
        JCJavaClassLoader classLoader = getJavaRuntime().findJavaClassLoader(clID);
        if (classLoader == null) {
            classLoader = new JCJavaClassLoader(getJavaRuntime(), clID);
        }
        JCJavaObject javaObject = classLoader.getInternalObject();
        if (javaObject == null) {
            JCJavaClass javaClass = getJavaRuntime().findJavaClass(classLoaderName);
            if (javaClass == null) {
                javaClass = new JCJavaClass(getJavaRuntime(), classLoaderName);
            }
            ImagePointer objectPointer = fAddressSpace.getPointer(objectID);
            javaObject = new JCJavaObject(objectPointer, javaClass);
            classLoader.setObject(javaObject);
        }
        return classLoader;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : JCJavaObject(com.ibm.dtfj.java.javacore.JCJavaObject) ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaClassLoader(com.ibm.dtfj.java.javacore.JCJavaClassLoader) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass)

Example 2 with JCJavaClassLoader

use of com.ibm.dtfj.java.javacore.JCJavaClassLoader in project openj9 by eclipse.

the class JavaRuntimeBuilder method addClass.

/**
 * Note that even if a class was already registered with a class loader previously, it may contain incomplete data,
 * so this case has to be considered.
 */
public JavaClass addClass(JavaClassLoader jClassLoader, String name, long classID, long superClassID, String fileName) throws BuilderFailureException {
    try {
        JCJavaClassLoader classLoader = (JCJavaClassLoader) jClassLoader;
        JCJavaClass jClass = generateJavaClass(getJavaRuntime(), name, classID);
        jClass.setJavaSuperClass(superClassID);
        jClass.setClassLoader(classLoader);
        ImagePointer ip = jClass.getID();
        if (ip != null) {
            classLoader.addClass(name, ip);
        } else {
            if (classLoader.internalGetClass(name) == null) {
                classLoader.addClass(name);
            }
        }
        return jClass;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaClassLoader(com.ibm.dtfj.java.javacore.JCJavaClassLoader) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)2 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)2 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)2 JCJavaClassLoader (com.ibm.dtfj.java.javacore.JCJavaClassLoader)2 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)2 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)1