T6405099.java revision 3294:9adfb22ff08f
125537Sdfr/* 259603Sdfr * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. 325537Sdfr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 425537Sdfr * 525537Sdfr * This code is free software; you can redistribute it and/or modify it 625537Sdfr * under the terms of the GNU General Public License version 2 only, as 725537Sdfr * published by the Free Software Foundation. 825537Sdfr * 925537Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT 1025537Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1125537Sdfr * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1225537Sdfr * version 2 for more details (a copy is included in the LICENSE file that 1325537Sdfr * accompanied this code). 1425537Sdfr * 1525537Sdfr * You should have received a copy of the GNU General Public License version 1625537Sdfr * 2 along with this work; if not, write to the Free Software Foundation, 1725537Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1825537Sdfr * 1925537Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2025537Sdfr * or visit www.oracle.com if you need additional information or have any 2125537Sdfr * questions. 2225537Sdfr */ 2325537Sdfr 2425537Sdfr/* 2525537Sdfr * @test 2650477Speter * @bug 6405099 2725537Sdfr * @summary Compiler crashes when javac encounters /usr/jdk/packges/lib/ext with no 777 permissions 2825537Sdfr * @modules jdk.compiler 2940159Speter */ 3040159Speter 3125537Sdfrimport java.io.*; 3225537Sdfr 3325537Sdfrpublic class T6405099 3425537Sdfr{ 3525537Sdfr public static void main(String[] args) { 3625537Sdfr File bad = new File("bad"); 3725537Sdfr try { 3825537Sdfr bad.mkdir(); 3982749Sdillon bad.setReadable(false); 4025537Sdfr bad.setExecutable(false); 4125537Sdfr 4240159Speter test(bad); 4340159Speter 4440159Speter } finally { 4540159Speter bad.setExecutable(true); 4640159Speter bad.setReadable(true); 4725537Sdfr } 4854655Seivind } 4959603Sdfr 5059603Sdfr static void test(File dir) { 5140961Speter String[] args = { 5240961Speter "-source", "8", "-target", "8", // -extdirs not allowed after -target 8 5340961Speter "-extdirs", dir.getPath(), 5440961Speter "-d", ".", 5583321Speter new File(System.getProperty("test.src", "."), "T6405099.java").getPath() 5659751Speter }; 5783321Speter 5883321Speter StringWriter sw = new StringWriter(); 5983321Speter PrintWriter pw = new PrintWriter(sw); 6059751Speter int rc = com.sun.tools.javac.Main.compile(args, pw); 6178161Speter pw.close(); 6278161Speter System.out.println(sw); 6378161Speter 6459751Speter if (rc != 0) 6559751Speter throw new Error("compilation failed"); 6640906Speter } 6731324Sbde} 6825537Sdfr