jdk/test/java/lang/instrument/ManifestTestApp.java
author dcubed
Mon, 24 Mar 2008 15:14:31 -0700
changeset 273 3d51c181a2e5
child 5506 202f599c92aa
permissions -rw-r--r--
6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names Summary: Attribute values should be extracted without leading or trailing whitespace. Reviewed-by: ohair, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
273
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     1
/*
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     2
 * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     4
 *
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     8
 *
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    13
 * accompanied this code).
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    14
 *
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    18
 *
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    21
 * have any questions.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    22
 */
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    23
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    24
public class ManifestTestApp {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    25
    public static void main(String args[]) {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    26
        System.out.println("Hello from ManifestTestApp!");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    27
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    28
        new ManifestTestApp().doTest();
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    29
        System.exit(0);
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    30
    }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    31
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    32
    private void doTest() {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    33
        try {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    34
            // load the class only found via the Boot-Class-Path attribute
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    35
            Object instance = loadExampleClass();
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    36
            if (instance.getClass().getClassLoader() == null) {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    37
                System.out.println("PASS: ExampleForBootClassPath was loaded" +
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    38
                    " by the boot class path loader.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    39
            } else {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    40
                System.out.println("FAIL: ExampleForBootClassPath was loaded" +
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    41
                    " by a non-boot class path loader.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    42
                System.exit(1);
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    43
            }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    44
        } catch (NoClassDefFoundError ncdfe) {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    45
            // This message just lets ManifestTest.sh know whether or
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    46
            // not ExampleForBootClassPath was loaded. Depending on
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    47
            // the current test case, that will be either a PASSing
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    48
            // condition or a FAILing condition as determined by
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    49
            // ManifestTest.sh.
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    50
            System.out.println("ExampleForBootClassPath was not loaded.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    51
        }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    52
    }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    53
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    54
    Object loadExampleClass() {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    55
        ExampleForBootClassPath instance = new ExampleForBootClassPath();
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    56
        System.out.println("ExampleForBootClassPath was loaded.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    57
        if (instance.fifteen() == 15) {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    58
            System.out.println("PASS: the correct" +
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    59
                " ExampleForBootClassPath was loaded.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    60
        } else {
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    61
            System.out.println("FAIL: the wrong ExampleForBootClassPath" +
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    62
                " was loaded.");
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    63
            System.out.println("FAIL: instance.fifteen()=" +
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    64
                instance.fifteen());
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    65
            System.exit(1);
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    66
        }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    67
        return instance;
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    68
    }
3d51c181a2e5 6274276: 3/2 java.lang.instrument JAR manifest processing does not remove spaces from class names
dcubed
parents:
diff changeset
    69
}