Search in sources :

Example 6 with JCInvalidArgumentsException

use of com.ibm.dtfj.java.javacore.JCInvalidArgumentsException 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)

Example 7 with JCInvalidArgumentsException

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

the class JavaRuntimeBuilder method addVMOption.

/**
 * Adds an individual VM option to JavaVMInitArgs, with 'extra information' field
 */
public void addVMOption(String option, long extraInfo) throws BuilderFailureException {
    if (fJavaVMInitArgs == null) {
        throw new BuilderFailureException("JCJavaVMInitArgs must be created before options added");
    }
    try {
        ImagePointer pointer = fAddressSpace.getPointer(extraInfo);
        fJavaVMInitArgs.addOption(new JCJavaVMOption(option, pointer));
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaVMOption(com.ibm.dtfj.java.javacore.JCJavaVMOption) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)

Example 8 with JCInvalidArgumentsException

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

the class JavaRuntimeBuilder method addJavaMonitor.

/**
 * Required: monitor ID (throws exception if invalid)
 * <br>
 * Optional: object ID, class name, monitor name, owning thread
 * @return successfully created JavaMonitor
 * @throws BuilderFailureException if an invalid monitor ID is passed.
 */
public JavaMonitor addJavaMonitor(String monitorName, long monitorID, long objectID, String className, long owningThread) throws BuilderFailureException {
    try {
        JCJavaMonitor monitor = getJavaRuntime().findMonitor(monitorID);
        if (monitor == null) {
            ImagePointer pointerMonitorID = fAddressSpace.getPointer(monitorID);
            monitor = new JCJavaMonitor(getJavaRuntime(), pointerMonitorID, monitorName);
        }
        monitor.setOwner(owningThread);
        if (className != null) {
            JCJavaClass jClass = generateJavaClass(getJavaRuntime(), className, IBuilderData.NOT_AVAILABLE);
            /*
				 * Add the object only if the class is also present and object ID is valid.
				 */
            if (jClass != null && fAddressSpace.isValidAddressID(objectID)) {
                ImagePointer pointerObjectID = fAddressSpace.getPointer(objectID);
                JCJavaObject jobject = new JCJavaObject(pointerObjectID, jClass);
                monitor.setObject(jobject);
            }
        }
        return monitor;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : JCJavaObject(com.ibm.dtfj.java.javacore.JCJavaObject) ImagePointer(com.ibm.dtfj.image.ImagePointer) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaMonitor(com.ibm.dtfj.java.javacore.JCJavaMonitor) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)8 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)8 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)7 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)6 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)4 JCJavaClassLoader (com.ibm.dtfj.java.javacore.JCJavaClassLoader)2 JCJavaThread (com.ibm.dtfj.java.javacore.JCJavaThread)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 ImageRegister (com.ibm.dtfj.image.ImageRegister)1 JCImageRegister (com.ibm.dtfj.image.javacore.JCImageRegister)1 JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 JCJavaLocation (com.ibm.dtfj.java.javacore.JCJavaLocation)1 JCJavaMethod (com.ibm.dtfj.java.javacore.JCJavaMethod)1 JCJavaMonitor (com.ibm.dtfj.java.javacore.JCJavaMonitor)1 JCJavaStackFrame (com.ibm.dtfj.java.javacore.JCJavaStackFrame)1 JCJavaVMOption (com.ibm.dtfj.java.javacore.JCJavaVMOption)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1