1 #! /bin/sh 2 3 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 # 6 # This code is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 only, as 8 # published by the Free Software Foundation. Oracle designates this 9 # particular file as subject to the "Classpath" exception as provided 10 # by Oracle in the LICENSE file that accompanied this code. 11 # 12 # This code is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 # version 2 for more details (a copy is included in the LICENSE file that 16 # accompanied this code). 17 # 18 # You should have received a copy of the GNU General Public License version 19 # 2 along with this work; if not, write to the Free Software Foundation, 20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 # 22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 # or visit www.oracle.com if you need additional information or have any 24 # questions. 25 26 # @test 27 # @summary Unit test for jmod command 28 29 set -e 30 31 BIN=${TESTJAVA:-../../../../../build}/bin 32 33 mk() { 34 d=`dirname $1` 35 if [ ! -d $d ]; then mkdir -p $d; fi 36 cat - >$1 37 } 38 39 rm -rf z.src 40 41 mk z.src/com.foo.bar/module-info.java <<EOF 42 module com.foo.bar @ 1.2.3_01-4a { 43 provides baz @ 2.0; 44 provides biz @ 3.4a; 45 permits com.foo.top; 46 permits com.foo.bottom; 47 class com.foo.bar.Main; 48 } 49 EOF 50 51 mk z.src/com.foo.byz/module-info.java <<EOF 52 module com.foo.byz @ 0.11-42 { } 53 EOF 54 55 mk z.src/com.foo.bar/com/foo/bar/Main.java <<EOF 56 package com.foo.bar; 57 public class Main { 58 public static void main(String[] args) { 59 System.out.println("Hello, world!"); 60 } 61 } 62 EOF 63 64 rm -rf z.modules && mkdir z.modules 65 $BIN/javac -source 8 -d z.modules -modulepath z.modules `find z.src -name '*.java'` 66 67 JAVA_MODULES=z.lib 68 export JAVA_MODULES 69 70 testjmod() { 71 createargs=$1 72 installargs=$2 73 rm -rf $JAVA_MODULES 74 $BIN/jmod ${TESTTOOLVMOPTS} create $createargs 75 $BIN/jmod ${TESTTOOLVMOPTS} id 76 $BIN/jmod ${TESTTOOLVMOPTS} install $installargs z.modules com.foo.bar 77 $BIN/jmod ${TESTTOOLVMOPTS} install $installargs z.modules com.foo.byz 78 $BIN/jmod ${TESTTOOLVMOPTS} list 79 $BIN/jmod ${TESTTOOLVMOPTS} list -v 80 $BIN/jmod ${TESTTOOLVMOPTS} dump-class com.foo.bar@1.2.3_01-4a com.foo.bar.Main z 81 if [ "$installargs" = "" ]; then 82 cmp z z.modules/com.foo.bar/com/foo/bar/Main.class 83 fi 84 } 85 86 # Test combinations of compressed/uncompressed module library and 87 # debug attributes stripped/not stripped during installation 88 # debug attributes stripped. 89 testjmod 90 testjmod -z 91 testjmod --enable-compression 92 testjmod "" -G 93 testjmod "" --strip-debug 94 testjmod -z -G