com.sun.tools.javac.file.ZipArchive.ZipFileObject Java Examples

The following examples show how to use com.sun.tools.javac.file.ZipArchive.ZipFileObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: T6705935.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #2
Source File: T6705935.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #3
Source File: T6705935.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #4
Source File: T6705935.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #5
Source File: T6705935.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #6
Source File: T6705935.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}
 
Example #7
Source File: T6705935.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() throws Exception {
    File java_home = new File(System.getProperty("java.home"));
    if (java_home.getName().equals("jre"))
        java_home = java_home.getParentFile();

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
    //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));

    for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                    "java.lang",
                                    Collections.singleton(JavaFileObject.Kind.CLASS),
                                    false)) {
        test++;

        if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
            System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
            skip++;
            continue;
        }

        //System.err.println(fo.getName());
        String p = fo.getName();
        int bra = p.indexOf("(");
        int ket = p.indexOf(")");
        //System.err.println(bra + "," + ket + "," + p.length());
        if (bra == -1 || ket != p.length() -1)
            throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
        String part1 = p.substring(0, bra);
        String part2 = p.substring(bra + 1, ket);
        //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
        if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
            throw new Exception("bad path: " + p);

    }

    if (test == 0)
        throw new Exception("no files found");

    if (skip == 0)
        System.out.println(test + " files found");
    else
        System.out.println(test + " files found, " + skip + " files skipped");

    if (test == skip)
        System.out.println("Warning: all files skipped; no platform classes found in zip files.");
}