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