IncrementBoxedAndAccess.java revision 3218:0c9553bc6bf5
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 */ 30 31import java.io.IOException; 32import java.nio.file.Files; 33import java.nio.file.Path; 34import java.nio.file.Paths; 35 36public class IncrementBoxedAndAccess { 37 public static void main(String... args) throws IOException { 38 new IncrementBoxedAndAccess().run(); 39 } 40 41 void run() throws IOException { 42 ToolBox tb = new ToolBox(); 43 44 Path expected = Paths.get("expected"); 45 Files.createDirectories(expected); 46 tb.cleanDirectory(expected); 47 tb.new JavacTask() 48 .sources("package p1;" + 49 "public class B {" + 50 " protected Integer i;" + 51 "}", 52 "package p2;" + 53 "public class S extends p1.B {" + 54 " public void i() { i++; }" + 55 " private class I {" + 56 " void i() { i++; }" + 57 " private class II {" + 58 " void i() { i++; }" + 59 " }" + 60 " }" + 61 "}") 62 .outdir(expected) 63 .run(); 64 65 Path actual = Paths.get("actual"); 66 Files.createDirectories(actual); 67 tb.cleanDirectory(actual); 68 tb.new JavacTask() 69 .sources("package p1;" + 70 "public class B {" + 71 " protected Integer i;" + 72 "}", 73 "package p2;" + 74 "public class S extends p1.B {" + 75 " public void i() { super.i++; }" + 76 " private class I {" + 77 " void i() { S.super.i++; }" + 78 " private class II {" + 79 " void i() { S.super.i++; }" + 80 " }" + 81 " }" + 82 "}") 83 .outdir(actual) 84 .run(); 85 } 86} 87