Java 类java.util.jar.Pack200.Packer 实例源码

项目:ramus    文件:Pack.java   
/**
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    if (args.length != 2) {
        System.err.println("command unput-directory output-directory");
        System.exit(1);
    }

    Packer packer = Pack200.newPacker();

    Map p = packer.properties();
    p.put(Packer.EFFORT, "9");
    p.put(Packer.SEGMENT_LIMIT, "-1");
    p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE);
    p.put(Packer.MODIFICATION_TIME, Packer.LATEST);
    p.put(Packer.DEFLATE_HINT, Packer.FALSE);
    p.put(Packer.CODE_ATTRIBUTE_PFX + "LineNumberTable", Packer.STRIP);
    p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);

    File inputDirectory = new File(args[0]);

    File outputDirectory = new File(args[1]);

    pack(packer, inputDirectory, outputDirectory);
}
项目:nbm-maven    文件:JarPack200.java   
protected void pack( Packer packer, File sourceJarFile, File targetFile, boolean useGZip )
    throws IOException
{
    final Closer closer = Closer.create();

    try
    {
        final JarFile jarFile = new JarFile( sourceJarFile );

        final OutputStream targetOut =
                    closer.register(
                            useGZip
                                ? new GZIPOutputStream( new FileOutputStream( targetFile ), 4096 )
                                : new BufferedOutputStream( new FileOutputStream( targetFile ), 4096 ) );

        packer.pack( jarFile, targetOut );
    }
    finally
    {
        closer.close();
    }
}
项目:openjdk9    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:jdk8u_jdk    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:webstart    文件:DefaultPack200Tool.java   
@Override
public void pack( File source, File destination, Map<String, String> props, boolean gzip )
        throws IOException
{
    JarFile jar = null;
    OutputStream out = null;
    try
    {
        out = new FileOutputStream( destination );
        if ( gzip )
        {
            out = new GZIPOutputStream( out )
            {
                {
                    def.setLevel( Deflater.BEST_COMPRESSION );
                }
            };
        }
        out = new BufferedOutputStream( out );

        jar = new JarFile( source, false );

        Pack200.Packer packer = Pack200.newPacker();
        packer.properties().putAll( props );
        packer.pack( jar, out );
    }
    finally
    {
        IOUtil.close( out );
        if ( jar != null )
        {
            jar.close();
        }
    }
}
项目:webstart    文件:DefaultPack200Tool.java   
@Override
public void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles )
        throws IOException
{
    // getLog().debug( "packJars for " + directory );
    File[] jarFiles = directory.listFiles( jarFileFilter );
    for ( File jarFile1 : jarFiles )
    {
        // getLog().debug( "packJars: " + jarFiles[i] );

        final String extension = gzip ? PACK_GZ_EXTENSION : PACK_EXTENSION;

        File jarFile = jarFile1;

        File pack200Jar = new File( jarFile.getParentFile(), jarFile.getName() + extension );

        deleteFile( pack200Jar );

        Map<String, String> propMap = new HashMap<>();
        // Work around a JDK bug affecting large JAR files, see MWEBSTART-125
        propMap.put( Pack200.Packer.SEGMENT_LIMIT, String.valueOf( -1 ) );

        // set passFiles if available
        if ( passFiles != null && !passFiles.isEmpty() )
        {
            for ( int j = 0; j < passFiles.size(); j++ )
            {
                propMap.put( Packer.PASS_FILE_PFX + j, passFiles.get( j ) );
            }
        }

        pack( jarFile, pack200Jar, propMap, gzip );
        setLastModified( pack200Jar, jarFile.lastModified() );
    }
}
项目:webstart    文件:DefaultPack200Tool.java   
@Override
public File packJar( File jarFile, boolean gzip, List<String> passFiles )
        throws IOException
{
    final String extension = gzip ? PACK_GZ_EXTENSION : PACK_EXTENSION;

    File pack200Jar = new File( jarFile.getParentFile(), jarFile.getName() + extension );

    deleteFile( pack200Jar );

    Map<String, String> propMap = new HashMap<>();
    // Work around a JDK bug affecting large JAR files, see MWEBSTART-125
    propMap.put( Pack200.Packer.SEGMENT_LIMIT, String.valueOf( -1 ) );

    // set passFiles if available
    if ( passFiles != null && !passFiles.isEmpty() )
    {
        for ( int j = 0; j < passFiles.size(); j++ )
        {
            propMap.put( Packer.PASS_FILE_PFX + j, passFiles.get( j ) );
        }
    }

    pack( jarFile, pack200Jar, propMap, gzip );
    setLastModified( pack200Jar, jarFile.lastModified() );
    return pack200Jar;
}
项目:infobip-open-jdk-8    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:jdk8u-dev-jdk    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:Lucee    文件:Pack200Util.java   
public static void jar2pack(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {
    // Create the Packer object
    Packer packer = Pack200.newPacker();

    // Initialize the state by setting the desired properties
    Map p = packer.properties();
    // take more time choosing codings for better compression
    p.put(Packer.EFFORT, "7");  // default is "5"
    // use largest-possible archive segments (>10% better compression).
    p.put(Packer.SEGMENT_LIMIT, "-1");
    // reorder files for better compression.
    p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE);
    // smear modification times to a single value.
    p.put(Packer.MODIFICATION_TIME, Packer.LATEST);
    // ignore all JAR deflation requests,
    // transmitting a single request to use "store" mode.
    p.put(Packer.DEFLATE_HINT, Packer.FALSE);
    // discard debug attributes
    p.put(Packer.CODE_ATTRIBUTE_PFX+"LineNumberTable", Packer.STRIP);
    // throw an error if an attribute is unrecognized
    p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);


    JarInputStream jis=null;
    os=new GZIPOutputStream(os);

    PrintStream err = System.err;
    try{
        System.setErr(new PrintStream(new DevNullOutputStream()));
        jis = new JarInputStream(is);
        packer.pack(jis, os);
    }
    finally{
        System.setErr(err);
        if(closeIS)Util.closeEL(jis);
        if(closeOS)Util.closeEL(os);
    }
}
项目:Lucee    文件:Pack200Util.java   
public static void jar2pack(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {
    // Create the Packer object
    Packer packer = Pack200.newPacker();

    // Initialize the state by setting the desired properties
    Map p = packer.properties();
    // take more time choosing codings for better compression
    p.put(Packer.EFFORT, "7");  // default is "5"
    // use largest-possible archive segments (>10% better compression).
    p.put(Packer.SEGMENT_LIMIT, "-1");
    // reorder files for better compression.
    p.put(Packer.KEEP_FILE_ORDER, Packer.FALSE);
    // smear modification times to a single value.
    p.put(Packer.MODIFICATION_TIME, Packer.LATEST);
    // ignore all JAR deflation requests,
    // transmitting a single request to use "store" mode.
    p.put(Packer.DEFLATE_HINT, Packer.FALSE);
    // discard debug attributes
    p.put(Packer.CODE_ATTRIBUTE_PFX+"LineNumberTable", Packer.STRIP);
    // throw an error if an attribute is unrecognized
    p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);


    JarInputStream jis=null;
    os=new GZIPOutputStream(os);

    PrintStream err = System.err;
    try{
        System.setErr(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
        jis = new JarInputStream(is);
        packer.pack(jis, os);
    }
    finally{
        System.setErr(err);
        if(closeIS)IOUtil.closeEL(jis);
        if(closeOS)IOUtil.closeEL(os);
    }
}
项目:jdk7-jdk    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:openjdk-source-code-learn    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:OLD-OpenJDK8    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:JAVA_UNIT    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:openjdk-jdk7u-jdk    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:dstack    文件:Compress.java   
public static final void compressJar(InputStream is, JarEntry entry, String output) throws IOException {
    JarInputStream jis = new JarInputStream(new NoCloseInputStream(is), true);
    if ( containsSha1(jis.getManifest()) ) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        System.out.println("Stripping signature on " + entry.getName());
        JarOutputStream jos = new JarOutputStream(baos);
        jos.setLevel(0);
        try {
            JarEntry jarEntry = null;
            while ( ( jarEntry = jis.getNextJarEntry() ) != null ) {
                jos.putNextEntry(new JarEntry(jarEntry.getName()));
                IOUtils.copy(jis, jos);
                jos.closeEntry();
            }
        } finally {
            IOUtils.closeQuietly(jos);
        }

        jis = new JarInputStream(new ByteArrayInputStream(baos.toByteArray()));
    }

    File outputFile = new File(output, entry.getName() + ".pack");
    FileUtils.forceMkdir(outputFile.getParentFile());

    System.out.println("Compressing " + entry.getName() + " to " + outputFile);
    FileOutputStream fos = new FileOutputStream(outputFile);
    try {
        Packer packer = Pack200.newPacker();
        packer.properties().put(Packer.DEFLATE_HINT, Packer.FALSE);
        packer.properties().put(Packer.EFFORT, "9");
        packer.pack(jis, fos);
    } finally {
        IOUtils.closeQuietly(fos);
    }
}
项目:nbm-maven    文件:JarPack200.java   
public static Packer populatePacker( Packer packer )
{
    final Map<String, String> packerProps =  packer.properties();

    packerProps.put( Packer.SEGMENT_LIMIT, SEGMENT_LIMIT );

    return packer;
}
项目:nbm-maven    文件:JarPack200.java   
public static Packer getDefaultPacker( int effort )
{
    final Packer packer = DefaultProperties.populatePacker( Pack200.newPacker() );

    if ( effort > -1 )
    {
        packer.properties().put( Packer.EFFORT, String.valueOf( effort ) );
    }

    return packer;
}
项目:openjdk-icedtea7    文件:PackageVersionTest.java   
static void verifyPack(String filename, int expected_major, int expected_minor) {

        File jarFileName = new File("test.jar");
        jarFileName.delete();
        String jargs[] = {
            "cvf",
            jarFileName.getName(),
            filename
        };
        Utils.jar(jargs);
        JarFile jfin = null;

        try {
            jfin = new JarFile(jarFileName);
            Packer packer = Pack200.newPacker();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            packer.pack(jfin, baos);
            baos.flush();
            baos.close();
            byte[] buf = baos.toByteArray();

            int minor = buf[4] & 0x000000ff;
            int major = buf[5] & 0x000000ff;

            if (major != expected_major || minor != expected_minor) {
                String msg =
                        String.format("test fails: expected:%d.%d but got %d.%d\n",
                        expected_major, expected_minor,
                        major, minor);
                throw new Error(msg);
            }

            System.out.println(filename + ": OK");
        } catch (IOException ioe) {
            throw new RuntimeException(ioe.getMessage());
        } finally {
            Utils.close((Closeable) jfin);
        }
    }
项目:ramus    文件:Pack.java   
private static void pack(Packer packer, File inputDirectory,
                         File outputDirectory) throws IOException, FileNotFoundException {
    File[] files = inputDirectory.listFiles();

    for (int i = 0; i < files.length; i++) {
        File file = files[i];
        if (file.isFile()) {
            if (file.getName().endsWith(".jar")) {

                String fn = file.getName().substring(0,
                        file.getName().length() - 4)
                        + ".pack";

                JarFile input = new JarFile(file);
                String fileName = outputDirectory.getAbsolutePath()
                        + File.separator + fn;
                OutputStream stream = new FileOutputStream(fileName);

                System.out
                        .println(file.getAbsolutePath() + "->" + fileName);
                packer.pack(input, stream);
            } else {
                FileInputStream fis = new FileInputStream(file);
                FileOutputStream fos = new FileOutputStream(new File(
                        outputDirectory, file.getName()));
                byte[] buff = new byte[1024 * 64];
                int r;
                while ((r = fis.read(buff)) > 0) {
                    fos.write(buff, 0, r);
                }
                fis.close();
                fos.close();
            }
        } else if (file.isDirectory()) {
            File outputDirectory2 = new File(outputDirectory, file
                    .getName());
            outputDirectory2.mkdir();
            pack(packer, file, outputDirectory2);
        }
    }
}
项目:jdk8u-jdk    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:jdk8u-jdk    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:openjdk-jdk10    文件:Pack200Props.java   
private static void verifyDefaults() {
    log.info("start");
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    log.info("fini");
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:openjdk9    文件:Pack200Props.java   
private static void verifyDefaults() {
    log.info("start");
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    log.info("fini");
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:jdk8u_jdk    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:jdk8u_jdk    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:lookaside_java-1.8.0-openjdk    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:infobip-open-jdk-8    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:infobip-open-jdk-8    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:jdk8u-dev-jdk    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:jdk8u-dev-jdk    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:jdk7-jdk    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:openjdk-source-code-learn    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:OLD-OpenJDK8    文件:Reflect.java   
public static void main(String[] args) {
    printMethods(Pack200.Packer.class);
    printMethods(Pack200.Unpacker.class);
    printMethods(Pack200.newPacker().getClass());
    printMethods(Pack200.newUnpacker().getClass());
}
项目:OLD-OpenJDK8    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}
项目:cn1    文件:Pack200Test.java   
public void testPacker() {
    Packer packer = Pack200.newPacker();
    assertEquals("org.apache.harmony.pack200.Pack200PackerAdapter", packer.getClass().getName());
}
项目:JAVA_UNIT    文件:Pack200Props.java   
private static void verifyDefaults() {
    Map<String, String> expectedDefaults = new HashMap<>();
    Packer p = Pack200.newPacker();
    expectedDefaults.put("com.sun.java.util.jar.pack.default.timezone",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.disable.native",
            p.FALSE);
    expectedDefaults.put("com.sun.java.util.jar.pack.verbose", "0");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "CompilationID", "RUH");
    expectedDefaults.put(p.CLASS_ATTRIBUTE_PFX + "SourceID", "RUH");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CharacterRangeTable",
            "NH[PHPOHIIH]");
    expectedDefaults.put(p.CODE_ATTRIBUTE_PFX + "CoverageTable",
            "NH[PHHII]");
    expectedDefaults.put(p.DEFLATE_HINT, p.KEEP);
    expectedDefaults.put(p.EFFORT, "5");
    expectedDefaults.put(p.KEEP_FILE_ORDER, p.TRUE);
    expectedDefaults.put(p.MODIFICATION_TIME, p.KEEP);
    expectedDefaults.put(p.SEGMENT_LIMIT, "-1");
    expectedDefaults.put(p.UNKNOWN_ATTRIBUTE, p.PASS);

    Map<String, String> props = p.properties();
    int errors = 0;
    for (String key : expectedDefaults.keySet()) {
        String def = expectedDefaults.get(key);
        String x = props.get(key);
        if (x == null) {
            System.out.println("Error: key not found:" + key);
            errors++;
        } else {
            if (!def.equals(x)) {
                System.out.println("Error: key " + key
                        + "\n  value expected: " + def
                        + "\n  value obtained: " + x);
                errors++;
            }
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors +
                " error(s) encountered in default properties verification");
    }
}