Search in sources :

Example 41 with IllegalArgumentException

use of java.lang.IllegalArgumentException in project openj9 by eclipse.

the class CreateTestObjectJar method main.

public static void main(String[] args) throws Throwable {
    File testDir = new File(args[0]);
    String testType = args[1];
    String jarFileName = null;
    ClassReader cr = new ClassReader("java/lang/Object");
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
    FieldVisitor fv = null;
    cr.accept(cw, 0);
    if (!testDir.isDirectory()) {
        printUsage();
        throw new IllegalArgumentException("Invalid directory: " + testDir.getPath());
    }
    /* Modify the Object class according with the test type */
    if (testType.equalsIgnoreCase("d")) {
        fv = cw.visitField(ACC_PRIVATE, "d", "D", null, null);
        jarFileName = "object_d.jar";
    } else if (testType.equalsIgnoreCase("i")) {
        fv = cw.visitField(ACC_PRIVATE, "i", "I", null, null);
        jarFileName = "object_i.jar";
    } else if (testType.equalsIgnoreCase("ii")) {
        fv = cw.visitField(ACC_PRIVATE, "i", "I", null, null);
        fv = cw.visitField(ACC_PRIVATE, "ii", "I", null, null);
        jarFileName = "object_ii.jar";
    } else if (testType.equalsIgnoreCase("iii")) {
        fv = cw.visitField(ACC_PRIVATE, "i", "I", null, null);
        fv = cw.visitField(ACC_PRIVATE, "ii", "I", null, null);
        fv = cw.visitField(ACC_PRIVATE, "iii", "I", null, null);
        jarFileName = "object_iii.jar";
    } else {
        printUsage();
        throw new IllegalArgumentException("Invalid test type: " + testType);
    }
    if (null != fv) {
        fv.visitEnd();
    }
    /* Write the final jar file with the modified Object class in it */
    if (null != jarFileName) {
        ZipOutputStream outJar = new ZipOutputStream(new FileOutputStream(testDir.getPath() + "/" + jarFileName));
        outJar.putNextEntry(new ZipEntry("java/lang/Object.class"));
        ByteArrayInputStream inJar = new ByteArrayInputStream(cw.toByteArray());
        int len;
        byte[] buf = new byte[bufLen];
        while ((len = inJar.read(buf)) > 0) {
            outJar.write(buf, 0, len);
        }
        outJar.closeEntry();
        outJar.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) ZipEntry(java.util.zip.ZipEntry) ClassReader(jdk.internal.org.objectweb.asm.ClassReader) File(java.io.File) FieldVisitor(jdk.internal.org.objectweb.asm.FieldVisitor) ClassWriter(jdk.internal.org.objectweb.asm.ClassWriter) IllegalArgumentException(java.lang.IllegalArgumentException)

Aggregations

IllegalArgumentException (java.lang.IllegalArgumentException)41 IOException (java.io.IOException)10 MediaPlayer (android.media.MediaPlayer)6 Surface (android.view.Surface)6 IndexOutOfBoundsException (java.lang.IndexOutOfBoundsException)4 RC2ParameterSpec (javax.crypto.spec.RC2ParameterSpec)4 URISyntaxException (java.net.URISyntaxException)3 Properties (java.util.Properties)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 Registrant (android.os.Registrant)2 ArrayIndexOutOfBoundsException (java.lang.ArrayIndexOutOfBoundsException)2 NullPointerException (java.lang.NullPointerException)2 IvParameterSpec (javax.crypto.spec.IvParameterSpec)2 WallpaperManager (android.app.WallpaperManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 Point (android.graphics.Point)1 Bundle (android.os.Bundle)1 CropActivity (com.android.gallery3d.filtershow.crop.CropActivity)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1