< prev index next >

test/langtools/tools/javac/nativeHeaders/NativeHeaderTest.java

Print this page


   1 /*
   2  * Copyright (c) 2012, 2015, 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  */


 105 
 106         test(rk, gk, files, expect);
 107     }
 108 
 109     @Test
 110     void syntheticClassTest(RunKind rk, GenKind gk) throws Exception {
 111         List<File> files = new ArrayList<File>();
 112         files.add(createFile("p/C.java",
 113                 "class C {\n"
 114                 + "    private C() { }\n"
 115                 + "    class Inner extends C { native void m(); }\n"
 116                 + "}"));
 117 
 118         Set<String> expect = createSet("C_Inner.h");
 119         if (gk == GenKind.FULL) expect.add("C.h");
 120 
 121         test(rk, gk, files, expect);
 122 
 123         // double check the synthetic class was generated
 124         checkEqual("generatedClasses",
 125                 createSet("C.class", "C$1.class", "C$Inner.class"),
 126                 createSet(classesDir.list()));
 127     }
 128 
 129     @Test
 130     void annoTest(RunKind rk, GenKind gk) throws Exception {
 131         List<File> files = new ArrayList<File>();
 132         files.add(createFile("p/C.java",
 133                 "class C { @java.lang.annotation.Native public static final int i = 1907; }"));
 134 
 135         Set<String> expect = createSet("C.h");
 136 
 137         test(rk, gk, files, expect);
 138     }
 139 
 140     @Test
 141     void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
 142         List<File> files = new ArrayList<File>();
 143         files.add(createFile("p/C.java",
 144                 "class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }"));
 145 


   1 /*
   2  * Copyright (c) 2012, 2018, 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  */


 105 
 106         test(rk, gk, files, expect);
 107     }
 108 
 109     @Test
 110     void syntheticClassTest(RunKind rk, GenKind gk) throws Exception {
 111         List<File> files = new ArrayList<File>();
 112         files.add(createFile("p/C.java",
 113                 "class C {\n"
 114                 + "    private C() { }\n"
 115                 + "    class Inner extends C { native void m(); }\n"
 116                 + "}"));
 117 
 118         Set<String> expect = createSet("C_Inner.h");
 119         if (gk == GenKind.FULL) expect.add("C.h");
 120 
 121         test(rk, gk, files, expect);
 122 
 123         // double check the synthetic class was generated
 124         checkEqual("generatedClasses",
 125                 createSet("C.class", "C$Inner.class"),
 126                 createSet(classesDir.list()));
 127     }
 128 
 129     @Test
 130     void annoTest(RunKind rk, GenKind gk) throws Exception {
 131         List<File> files = new ArrayList<File>();
 132         files.add(createFile("p/C.java",
 133                 "class C { @java.lang.annotation.Native public static final int i = 1907; }"));
 134 
 135         Set<String> expect = createSet("C.h");
 136 
 137         test(rk, gk, files, expect);
 138     }
 139 
 140     @Test
 141     void annoNestedClassTest(RunKind rk, GenKind gk) throws Exception {
 142         List<File> files = new ArrayList<File>();
 143         files.add(createFile("p/C.java",
 144                 "class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }"));
 145 


< prev index next >