jdk/test/tools/jar/multiRelease/data/runtimetest/v10/testpackage/Main.java
author xiaofeya
Wed, 11 Jan 2017 08:53:59 -0800
changeset 43065 23e5bc13ec20
permissions -rw-r--r--
8075884: check runtime usage tests with multi-release jar files Reviewed-by: psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43065
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     1
/*
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     4
 *
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     7
 * published by the Free Software Foundation.
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     8
 *
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    13
 * accompanied this code).
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    14
 *
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    18
 *
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    21
 * questions.
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    22
 */
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    23
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    24
package testpackage;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    25
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    26
import java.io.BufferedReader;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    27
import java.io.IOException;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    28
import java.io.InputStream;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    29
import java.io.InputStreamReader;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    30
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    31
public class Main {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    32
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    33
    private static final int MAIN_VERSION = 10;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    34
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    35
    public static void main(String[] args) {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    36
        System.out.println("Main version: " + getMainVersion());
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    37
        System.out.println("Helpers version: " + getHelperVersion());
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    38
        System.out.println("Resource version: " + getResourceVersion());
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    39
    }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    40
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    41
    public static int getMainVersion() {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    42
        return MAIN_VERSION;
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    43
    }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    44
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    45
    public static int getHelperVersion() {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    46
        return testpackage.Helper.getHelperVersion();
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    47
    }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    48
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    49
    public static int getResourceVersion() {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    50
        ClassLoader cl = Main.class.getClassLoader();
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    51
        InputStream ris = cl.getResourceAsStream("versionResource");
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    52
        if (ris == null) {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    53
            throw new Error("Test issue: resource versionResource"
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    54
                    + " cannot be loaded!");
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    55
        }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    56
        try (BufferedReader br = new BufferedReader(new InputStreamReader(ris))) {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    57
            return Integer.parseInt(br.readLine());
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    58
        } catch (IOException ioe) {
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    59
            throw new Error("Unexpected issue", ioe);
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    60
        }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    61
    }
23e5bc13ec20 8075884: check runtime usage tests with multi-release jar files
xiaofeya
parents:
diff changeset
    62
}