IncCompileUpdateNative.java revision 2958:27da0c3ac83a
1254885Sdumbbell/* 2254885Sdumbbell * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3254885Sdumbbell * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4254885Sdumbbell * 5254885Sdumbbell * This code is free software; you can redistribute it and/or modify it 6254885Sdumbbell * under the terms of the GNU General Public License version 2 only, as 7254885Sdumbbell * published by the Free Software Foundation. 8254885Sdumbbell * 9254885Sdumbbell * This code is distributed in the hope that it will be useful, but WITHOUT 10254885Sdumbbell * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11254885Sdumbbell * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12254885Sdumbbell * version 2 for more details (a copy is included in the LICENSE file that 13254885Sdumbbell * accompanied this code). 14254885Sdumbbell * 15254885Sdumbbell * You should have received a copy of the GNU General Public License version 16254885Sdumbbell * 2 along with this work; if not, write to the Free Software Foundation, 17254885Sdumbbell * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18254885Sdumbbell * 19254885Sdumbbell * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20254885Sdumbbell * or visit www.oracle.com if you need additional information or have any 21254885Sdumbbell * questions. 22254885Sdumbbell */ 23254885Sdumbbell 24254885Sdumbbell/* 25254885Sdumbbell * @test 26254885Sdumbbell * @summary Verify native files are rewritten 27254885Sdumbbell * @bug 8054689 28254885Sdumbbell * @author Fredrik O 29254885Sdumbbell * @author sogoel (rewrite) 30254885Sdumbbell * @library /tools/lib 31254885Sdumbbell * @modules jdk.compiler/com.sun.tools.javac.api 32254885Sdumbbell * jdk.compiler/com.sun.tools.javac.file 33254885Sdumbbell * jdk.compiler/com.sun.tools.javac.main 34254885Sdumbbell * jdk.compiler/com.sun.tools.sjavac 35254885Sdumbbell * @build Wrapper ToolBox 36254885Sdumbbell * @run main Wrapper IncCompileUpdateNative 37254885Sdumbbell */ 38254885Sdumbbell 39254885Sdumbbellimport java.util.*; 40254885Sdumbbellimport java.nio.file.*; 41254885Sdumbbell 42254885Sdumbbellpublic class IncCompileUpdateNative extends SJavacTester { 43254885Sdumbbell public static void main(String... args) throws Exception { 44254885Sdumbbell IncCompileUpdateNative un = new IncCompileUpdateNative(); 45254885Sdumbbell un.test(); 46254885Sdumbbell } 47254885Sdumbbell 48254885Sdumbbell // Remember the previous bin and headers state here. 49254885Sdumbbell Map<String,Long> previous_bin_state; 50254885Sdumbbell Map<String,Long> previous_headers_state; 51254885Sdumbbell ToolBox tb = new ToolBox(); 52254885Sdumbbell 53254885Sdumbbell void test() throws Exception { 54254885Sdumbbell clean(TEST_ROOT); 55254885Sdumbbell Files.createDirectories(GENSRC); 56254885Sdumbbell Files.createDirectories(BIN); 57254885Sdumbbell Files.createDirectories(HEADERS); 58254885Sdumbbell 59254885Sdumbbell initialCompile(); 60254885Sdumbbell incrementalCompileChangeNative(); 61254885Sdumbbell 62254885Sdumbbell clean(GENSRC, BIN, HEADERS); 63254885Sdumbbell } 64254885Sdumbbell 65254885Sdumbbell // Update B.java with a new value for the final static annotated with @Native 66254885Sdumbbell // Verify that beta_B.h is rewritten again 67254885Sdumbbell void incrementalCompileChangeNative() throws Exception { 68254885Sdumbbell previous_bin_state = collectState(BIN); 69254885Sdumbbell previous_headers_state = collectState(HEADERS); 70254885Sdumbbell System.out.println("\nIn incrementalCompileChangeNative() "); 71254885Sdumbbell System.out.println("Verify that beta_B.h is rewritten again"); 72254885Sdumbbell tb.writeFile(GENSRC.resolve("beta/B.java"), 73254885Sdumbbell "package beta; import alfa.omega.A; public class B {"+ 74254885Sdumbbell "private int b() { return A.DEFINITION; } "+ 75280183Sdumbbell "@java.lang.annotation.Native final static int alfa = 43; }"); 76254885Sdumbbell 77254885Sdumbbell compile(GENSRC.toString(), 78280183Sdumbbell "-d", BIN.toString(), 79254885Sdumbbell "-h", HEADERS.toString(), 80254885Sdumbbell "-j", "1", 81254885Sdumbbell SERVER_ARG, 82254885Sdumbbell "--log=debug"); 83254885Sdumbbell Map<String,Long> new_bin_state = collectState(BIN); 84254885Sdumbbell verifyNewerFiles(previous_bin_state, new_bin_state, 85254885Sdumbbell BIN + "/beta/B.class", 86254885Sdumbbell BIN + "/beta/BINT.class", 87254885Sdumbbell BIN + "/javac_state"); 88254885Sdumbbell previous_bin_state = new_bin_state; 89254885Sdumbbell 90254885Sdumbbell Map<String,Long> new_headers_state = collectState(HEADERS); 91254885Sdumbbell verifyNewerFiles(previous_headers_state, new_headers_state, 92254885Sdumbbell HEADERS + "/beta_B.h"); 93254885Sdumbbell previous_headers_state = new_headers_state; 94254885Sdumbbell } 95254885Sdumbbell} 96254885Sdumbbell