1/* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/** 25 * @test 26 * @bug 8143388 27 * @summary Verify that boxed postfix operator works properly when referring to super class' field. 28 * @library /tools/lib 29 * @modules jdk.compiler/com.sun.tools.javac.api 30 * jdk.compiler/com.sun.tools.javac.main 31 * jdk.jdeps/com.sun.tools.javap 32 * @build toolbox.ToolBox toolbox.JavacTask 33 * @run main IncrementBoxedAndAccess 34 */ 35 36import java.io.IOException; 37import java.nio.file.Files; 38import java.nio.file.Path; 39import java.nio.file.Paths; 40 41import toolbox.JavacTask; 42import toolbox.ToolBox; 43 44public class IncrementBoxedAndAccess { 45 public static void main(String... args) throws IOException { 46 new IncrementBoxedAndAccess().run(); 47 } 48 49 void run() throws IOException { 50 ToolBox tb = new ToolBox(); 51 52 Path expected = Paths.get("expected"); 53 Files.createDirectories(expected); 54 tb.cleanDirectory(expected); 55 new JavacTask(tb) 56 .sources("package p1;" + 57 "public class B {" + 58 " protected Integer i;" + 59 "}", 60 "package p2;" + 61 "public class S extends p1.B {" + 62 " public void i() { i++; }" + 63 " private class I {" + 64 " void i() { i++; }" + 65 " private class II {" + 66 " void i() { i++; }" + 67 " }" + 68 " }" + 69 "}") 70 .outdir(expected) 71 .run(); 72 73 Path actual = Paths.get("actual"); 74 Files.createDirectories(actual); 75 tb.cleanDirectory(actual); 76 new JavacTask(tb) 77 .sources("package p1;" + 78 "public class B {" + 79 " protected Integer i;" + 80 "}", 81 "package p2;" + 82 "public class S extends p1.B {" + 83 " public void i() { super.i++; }" + 84 " private class I {" + 85 " void i() { S.super.i++; }" + 86 " private class II {" + 87 " void i() { S.super.i++; }" + 88 " }" + 89 " }" + 90 "}") 91 .outdir(actual) 92 .run(); 93 } 94} 95