aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/java
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/java')
-rw-r--r--meson/test cases/java/1 basic/com/mesonbuild/Simple.java7
-rw-r--r--meson/test cases/java/1 basic/meson.build11
-rw-r--r--meson/test cases/java/1 basic/test.json5
-rw-r--r--meson/test cases/java/2 subdir/meson.build3
-rw-r--r--meson/test cases/java/2 subdir/sub/com/mesonbuild/Simple.java8
-rw-r--r--meson/test cases/java/2 subdir/sub/com/mesonbuild/TextPrinter.java14
-rw-r--r--meson/test cases/java/2 subdir/sub/meson.build5
-rw-r--r--meson/test cases/java/3 args/com/mesonbuild/Simple.java7
-rw-r--r--meson/test cases/java/3 args/meson.build9
-rw-r--r--meson/test cases/java/4 inner class/com/mesonbuild/Simple.java15
-rw-r--r--meson/test cases/java/4 inner class/meson.build5
-rw-r--r--meson/test cases/java/5 includedirs/com/mesonbuild/Simple.java8
-rw-r--r--meson/test cases/java/5 includedirs/com/mesonbuild/TextPrinter.java14
-rw-r--r--meson/test cases/java/5 includedirs/meson.build14
-rw-r--r--meson/test cases/java/6 codegen/com/mesonbuild/Config.java.in5
-rw-r--r--meson/test cases/java/6 codegen/com/mesonbuild/Simple.java12
-rw-r--r--meson/test cases/java/6 codegen/com/mesonbuild/TextPrinter.java14
-rw-r--r--meson/test cases/java/6 codegen/com/mesonbuild/meson.build6
-rw-r--r--meson/test cases/java/6 codegen/meson.build15
-rw-r--r--meson/test cases/java/7 linking/com/mesonbuild/Linking.java9
-rw-r--r--meson/test cases/java/7 linking/meson.build8
-rw-r--r--meson/test cases/java/7 linking/sub/com/mesonbuild/SimpleLib.java7
-rw-r--r--meson/test cases/java/7 linking/sub/meson.build2
-rw-r--r--meson/test cases/java/8 codegen custom target/com/mesonbuild/Config.java.in5
-rw-r--r--meson/test cases/java/8 codegen custom target/com/mesonbuild/Simple.java12
-rw-r--r--meson/test cases/java/8 codegen custom target/com/mesonbuild/TextPrinter.java14
-rw-r--r--meson/test cases/java/8 codegen custom target/com/mesonbuild/meson.build8
-rw-r--r--meson/test cases/java/8 codegen custom target/meson.build15
-rw-r--r--meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.c9
-rw-r--r--meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.h21
-rw-r--r--meson/test cases/java/9 jdk/lib/meson.build14
-rw-r--r--meson/test cases/java/9 jdk/lib/native.c11
-rw-r--r--meson/test cases/java/9 jdk/meson.build18
-rw-r--r--meson/test cases/java/9 jdk/src/com/mesonbuild/JdkTest.java15
-rw-r--r--meson/test cases/java/9 jdk/src/meson.build17
35 files changed, 362 insertions, 0 deletions
diff --git a/meson/test cases/java/1 basic/com/mesonbuild/Simple.java b/meson/test cases/java/1 basic/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..325a49a21
--- /dev/null
+++ b/meson/test cases/java/1 basic/com/mesonbuild/Simple.java
@@ -0,0 +1,7 @@
+package com.mesonbuild;
+
+class Simple {
+ public static void main(String [] args) {
+ System.out.println("Java is working.\n");
+ }
+}
diff --git a/meson/test cases/java/1 basic/meson.build b/meson/test cases/java/1 basic/meson.build
new file mode 100644
index 000000000..ef1a4b74c
--- /dev/null
+++ b/meson/test cases/java/1 basic/meson.build
@@ -0,0 +1,11 @@
+project('simplejava', 'java')
+
+javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
+ main_class : 'com.mesonbuild.Simple',
+ install : true,
+ install_dir : get_option('bindir'))
+test('mytest', javaprog)
+
+jc = meson.get_compiler('java')
+message(jc.get_id())
+message(jc.get_linker_id())
diff --git a/meson/test cases/java/1 basic/test.json b/meson/test cases/java/1 basic/test.json
new file mode 100644
index 000000000..b5b1539ad
--- /dev/null
+++ b/meson/test cases/java/1 basic/test.json
@@ -0,0 +1,5 @@
+{
+ "installed": [
+ {"type": "file", "file": "usr/bin/myprog.jar"}
+ ]
+}
diff --git a/meson/test cases/java/2 subdir/meson.build b/meson/test cases/java/2 subdir/meson.build
new file mode 100644
index 000000000..5aaa02881
--- /dev/null
+++ b/meson/test cases/java/2 subdir/meson.build
@@ -0,0 +1,3 @@
+project('subdirjava', 'java')
+
+subdir('sub')
diff --git a/meson/test cases/java/2 subdir/sub/com/mesonbuild/Simple.java b/meson/test cases/java/2 subdir/sub/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..05a73accc
--- /dev/null
+++ b/meson/test cases/java/2 subdir/sub/com/mesonbuild/Simple.java
@@ -0,0 +1,8 @@
+package com.mesonbuild;
+
+class Simple {
+ public static void main(String [] args) {
+ TextPrinter t = new TextPrinter("Printing from Java.");
+ t.print();
+ }
+}
diff --git a/meson/test cases/java/2 subdir/sub/com/mesonbuild/TextPrinter.java b/meson/test cases/java/2 subdir/sub/com/mesonbuild/TextPrinter.java
new file mode 100644
index 000000000..7e330a60b
--- /dev/null
+++ b/meson/test cases/java/2 subdir/sub/com/mesonbuild/TextPrinter.java
@@ -0,0 +1,14 @@
+package com.mesonbuild;
+
+class TextPrinter {
+
+ private String msg;
+
+ TextPrinter(String s) {
+ msg = s;
+ }
+
+ public void print() {
+ System.out.println(msg);
+ }
+}
diff --git a/meson/test cases/java/2 subdir/sub/meson.build b/meson/test cases/java/2 subdir/sub/meson.build
new file mode 100644
index 000000000..2111c06c6
--- /dev/null
+++ b/meson/test cases/java/2 subdir/sub/meson.build
@@ -0,0 +1,5 @@
+javaprog = jar('myprog',
+ 'com/mesonbuild/Simple.java',
+ 'com/mesonbuild/TextPrinter.java',
+ main_class : 'com.mesonbuild.Simple')
+test('subdirtest', javaprog)
diff --git a/meson/test cases/java/3 args/com/mesonbuild/Simple.java b/meson/test cases/java/3 args/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..325a49a21
--- /dev/null
+++ b/meson/test cases/java/3 args/com/mesonbuild/Simple.java
@@ -0,0 +1,7 @@
+package com.mesonbuild;
+
+class Simple {
+ public static void main(String [] args) {
+ System.out.println("Java is working.\n");
+ }
+}
diff --git a/meson/test cases/java/3 args/meson.build b/meson/test cases/java/3 args/meson.build
new file mode 100644
index 000000000..451e42d97
--- /dev/null
+++ b/meson/test cases/java/3 args/meson.build
@@ -0,0 +1,9 @@
+project('simplejava', 'java')
+
+add_project_arguments('-target', '1.7', language : 'java')
+
+javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
+ main_class : 'com.mesonbuild.Simple',
+ java_args : ['-source', '1.7'])
+test('mytest', javaprog)
+
diff --git a/meson/test cases/java/4 inner class/com/mesonbuild/Simple.java b/meson/test cases/java/4 inner class/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..fd0e0bfaa
--- /dev/null
+++ b/meson/test cases/java/4 inner class/com/mesonbuild/Simple.java
@@ -0,0 +1,15 @@
+package com.mesonbuild;
+
+class Simple {
+ class Inner {
+ public String getString() {
+ return "Inner class is working.\n";
+ }
+ }
+
+ public static void main(String [] args) {
+ Simple s = new Simple();
+ Simple.Inner ic = s.new Inner();
+ System.out.println(ic.getString());
+ }
+}
diff --git a/meson/test cases/java/4 inner class/meson.build b/meson/test cases/java/4 inner class/meson.build
new file mode 100644
index 000000000..bed5c0f67
--- /dev/null
+++ b/meson/test cases/java/4 inner class/meson.build
@@ -0,0 +1,5 @@
+project('simplejava', 'java')
+
+javaprog = jar('myprog', 'com/mesonbuild/Simple.java',
+ main_class : 'com.mesonbuild.Simple')
+test('mytest', javaprog)
diff --git a/meson/test cases/java/5 includedirs/com/mesonbuild/Simple.java b/meson/test cases/java/5 includedirs/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..05a73accc
--- /dev/null
+++ b/meson/test cases/java/5 includedirs/com/mesonbuild/Simple.java
@@ -0,0 +1,8 @@
+package com.mesonbuild;
+
+class Simple {
+ public static void main(String [] args) {
+ TextPrinter t = new TextPrinter("Printing from Java.");
+ t.print();
+ }
+}
diff --git a/meson/test cases/java/5 includedirs/com/mesonbuild/TextPrinter.java b/meson/test cases/java/5 includedirs/com/mesonbuild/TextPrinter.java
new file mode 100644
index 000000000..7e330a60b
--- /dev/null
+++ b/meson/test cases/java/5 includedirs/com/mesonbuild/TextPrinter.java
@@ -0,0 +1,14 @@
+package com.mesonbuild;
+
+class TextPrinter {
+
+ private String msg;
+
+ TextPrinter(String s) {
+ msg = s;
+ }
+
+ public void print() {
+ System.out.println(msg);
+ }
+}
diff --git a/meson/test cases/java/5 includedirs/meson.build b/meson/test cases/java/5 includedirs/meson.build
new file mode 100644
index 000000000..cf0b56506
--- /dev/null
+++ b/meson/test cases/java/5 includedirs/meson.build
@@ -0,0 +1,14 @@
+# The Ninja backend used to try and pass -sourcepath repeatedly for
+# multiple includes which would discard prior includes. Since this
+# won't compile without the '.' include, this ensures that multiple
+# paths are passed in a [semi-]colon separated list instead...
+
+project('includedirsjava', 'java')
+
+javaprog = jar('myprog',
+ 'com/mesonbuild/Simple.java',
+ 'com/mesonbuild/TextPrinter.java',
+ main_class : 'com.mesonbuild.Simple',
+ include_directories : [ include_directories('com'),
+ include_directories('com/mesonbuild') ])
+test('subdirtest', javaprog)
diff --git a/meson/test cases/java/6 codegen/com/mesonbuild/Config.java.in b/meson/test cases/java/6 codegen/com/mesonbuild/Config.java.in
new file mode 100644
index 000000000..fcc88117e
--- /dev/null
+++ b/meson/test cases/java/6 codegen/com/mesonbuild/Config.java.in
@@ -0,0 +1,5 @@
+package com.mesonbuild;
+
+public class Config {
+ public static final boolean FOOBAR = @foobar@;
+}
diff --git a/meson/test cases/java/6 codegen/com/mesonbuild/Simple.java b/meson/test cases/java/6 codegen/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..df3c53df3
--- /dev/null
+++ b/meson/test cases/java/6 codegen/com/mesonbuild/Simple.java
@@ -0,0 +1,12 @@
+package com.mesonbuild;
+
+import com.mesonbuild.Config;
+
+class Simple {
+ public static void main(String [] args) {
+ if (Config.FOOBAR) {
+ TextPrinter t = new TextPrinter("Printing from Java.");
+ t.print();
+ }
+ }
+}
diff --git a/meson/test cases/java/6 codegen/com/mesonbuild/TextPrinter.java b/meson/test cases/java/6 codegen/com/mesonbuild/TextPrinter.java
new file mode 100644
index 000000000..7e330a60b
--- /dev/null
+++ b/meson/test cases/java/6 codegen/com/mesonbuild/TextPrinter.java
@@ -0,0 +1,14 @@
+package com.mesonbuild;
+
+class TextPrinter {
+
+ private String msg;
+
+ TextPrinter(String s) {
+ msg = s;
+ }
+
+ public void print() {
+ System.out.println(msg);
+ }
+}
diff --git a/meson/test cases/java/6 codegen/com/mesonbuild/meson.build b/meson/test cases/java/6 codegen/com/mesonbuild/meson.build
new file mode 100644
index 000000000..188bedf10
--- /dev/null
+++ b/meson/test cases/java/6 codegen/com/mesonbuild/meson.build
@@ -0,0 +1,6 @@
+
+conf_data = configuration_data()
+conf_data.set('foobar', 'true')
+config_file = configure_file(input : 'Config.java.in',
+ output : 'Config.java',
+ configuration : conf_data)
diff --git a/meson/test cases/java/6 codegen/meson.build b/meson/test cases/java/6 codegen/meson.build
new file mode 100644
index 000000000..f85d45ae0
--- /dev/null
+++ b/meson/test cases/java/6 codegen/meson.build
@@ -0,0 +1,15 @@
+# If we generate code under the build directory then the backend needs to add
+# the build directory to the -sourcepath passed to javac otherwise the compiler
+# won't be able to handle the -implicit:class behaviour of automatically
+# compiling dependency classes.
+
+project('codegenjava', 'java')
+
+subdir('com/mesonbuild')
+
+javaprog = jar('myprog',
+ config_file,
+ 'com/mesonbuild/Simple.java',
+ 'com/mesonbuild/TextPrinter.java',
+ main_class : 'com.mesonbuild.Simple')
+test('subdirtest', javaprog)
diff --git a/meson/test cases/java/7 linking/com/mesonbuild/Linking.java b/meson/test cases/java/7 linking/com/mesonbuild/Linking.java
new file mode 100644
index 000000000..170e2aadb
--- /dev/null
+++ b/meson/test cases/java/7 linking/com/mesonbuild/Linking.java
@@ -0,0 +1,9 @@
+package com.mesonbuild;
+
+import com.mesonbuild.SimpleLib;
+
+class Linking {
+ public static void main(String [] args) {
+ SimpleLib.func();
+ }
+}
diff --git a/meson/test cases/java/7 linking/meson.build b/meson/test cases/java/7 linking/meson.build
new file mode 100644
index 000000000..0ae0db39a
--- /dev/null
+++ b/meson/test cases/java/7 linking/meson.build
@@ -0,0 +1,8 @@
+project('linkingjava', 'java')
+
+subdir('sub')
+
+javaprog = jar('myprog', 'com/mesonbuild/Linking.java',
+ main_class : 'com.mesonbuild.Linking',
+ link_with : simplelib)
+test('mytest', javaprog) \ No newline at end of file
diff --git a/meson/test cases/java/7 linking/sub/com/mesonbuild/SimpleLib.java b/meson/test cases/java/7 linking/sub/com/mesonbuild/SimpleLib.java
new file mode 100644
index 000000000..835b2e4da
--- /dev/null
+++ b/meson/test cases/java/7 linking/sub/com/mesonbuild/SimpleLib.java
@@ -0,0 +1,7 @@
+package com.mesonbuild;
+
+public class SimpleLib {
+ public static void func() {
+ System.out.println("Java linking is working.\n");
+ }
+}
diff --git a/meson/test cases/java/7 linking/sub/meson.build b/meson/test cases/java/7 linking/sub/meson.build
new file mode 100644
index 000000000..13fd202ed
--- /dev/null
+++ b/meson/test cases/java/7 linking/sub/meson.build
@@ -0,0 +1,2 @@
+simplelib = jar('simplelib',
+ 'com/mesonbuild/SimpleLib.java')
diff --git a/meson/test cases/java/8 codegen custom target/com/mesonbuild/Config.java.in b/meson/test cases/java/8 codegen custom target/com/mesonbuild/Config.java.in
new file mode 100644
index 000000000..8845985a9
--- /dev/null
+++ b/meson/test cases/java/8 codegen custom target/com/mesonbuild/Config.java.in
@@ -0,0 +1,5 @@
+package com.mesonbuild;
+
+public class Config {
+ public static final boolean FOOBAR = true;
+}
diff --git a/meson/test cases/java/8 codegen custom target/com/mesonbuild/Simple.java b/meson/test cases/java/8 codegen custom target/com/mesonbuild/Simple.java
new file mode 100644
index 000000000..df3c53df3
--- /dev/null
+++ b/meson/test cases/java/8 codegen custom target/com/mesonbuild/Simple.java
@@ -0,0 +1,12 @@
+package com.mesonbuild;
+
+import com.mesonbuild.Config;
+
+class Simple {
+ public static void main(String [] args) {
+ if (Config.FOOBAR) {
+ TextPrinter t = new TextPrinter("Printing from Java.");
+ t.print();
+ }
+ }
+}
diff --git a/meson/test cases/java/8 codegen custom target/com/mesonbuild/TextPrinter.java b/meson/test cases/java/8 codegen custom target/com/mesonbuild/TextPrinter.java
new file mode 100644
index 000000000..dc2771c37
--- /dev/null
+++ b/meson/test cases/java/8 codegen custom target/com/mesonbuild/TextPrinter.java
@@ -0,0 +1,14 @@
+package com.mesonbuild;
+
+class TextPrinter {
+
+ private String msg;
+
+ TextPrinter(String s) {
+ msg = s;
+ }
+
+ public void print() {
+ System.out.println(msg);
+ }
+}
diff --git a/meson/test cases/java/8 codegen custom target/com/mesonbuild/meson.build b/meson/test cases/java/8 codegen custom target/com/mesonbuild/meson.build
new file mode 100644
index 000000000..030994154
--- /dev/null
+++ b/meson/test cases/java/8 codegen custom target/com/mesonbuild/meson.build
@@ -0,0 +1,8 @@
+python = import('python').find_installation('python3')
+
+config_file = custom_target('confgen',
+ input : 'Config.java.in',
+ output : 'Config.java',
+ command : [python, '-c',
+ 'import shutil, sys, time; time.sleep(1); shutil.copy(sys.argv[1], sys.argv[2])',
+ '@INPUT@', '@OUTPUT@'])
diff --git a/meson/test cases/java/8 codegen custom target/meson.build b/meson/test cases/java/8 codegen custom target/meson.build
new file mode 100644
index 000000000..ab441a633
--- /dev/null
+++ b/meson/test cases/java/8 codegen custom target/meson.build
@@ -0,0 +1,15 @@
+# If we generate code under the build directory then the backend needs to add
+# the build directory to the -sourcepath passed to javac otherwise the compiler
+# won't be able to handle the -implicit:class behaviour of automatically
+# compiling dependency classes.
+
+project('codegenjava', 'java')
+
+subdir('com/mesonbuild')
+
+javaprog = jar('myprog',
+ config_file[0],
+ 'com/mesonbuild/Simple.java',
+ 'com/mesonbuild/TextPrinter.java',
+ main_class : 'com.mesonbuild.Simple')
+test('subdirtest', javaprog)
diff --git a/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.c b/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.c
new file mode 100644
index 000000000..075e37b2b
--- /dev/null
+++ b/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.c
@@ -0,0 +1,9 @@
+#include <jni.h>
+
+#include "com_mesonbuild_JdkTest.h"
+
+JNIEXPORT jint JNICALL Java_com_mesonbuild_JdkTest_jdk_1test
+ (JNIEnv *env, jclass clazz)
+{
+ return (jint)0xdeadbeef;
+}
diff --git a/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.h b/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.h
new file mode 100644
index 000000000..40083ac9b
--- /dev/null
+++ b/meson/test cases/java/9 jdk/lib/com_mesonbuild_JdkTest.h
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class com_mesonbuild_JdkTest */
+
+#ifndef _Included_com_mesonbuild_JdkTest
+#define _Included_com_mesonbuild_JdkTest
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_mesonbuild_JdkTest
+ * Method: jdk_test
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_mesonbuild_JdkTest_jdk_1test
+ (JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/meson/test cases/java/9 jdk/lib/meson.build b/meson/test cases/java/9 jdk/lib/meson.build
new file mode 100644
index 000000000..a94776972
--- /dev/null
+++ b/meson/test cases/java/9 jdk/lib/meson.build
@@ -0,0 +1,14 @@
+sources = files(
+ 'native.c',
+ 'com_mesonbuild_JdkTest.c',
+)
+
+jdkjava = shared_module(
+ 'jdkjava',
+ sources,
+ dependencies : [jdk],
+)
+
+jdkjava_dep = declare_dependency(
+ link_with : jdkjava,
+)
diff --git a/meson/test cases/java/9 jdk/lib/native.c b/meson/test cases/java/9 jdk/lib/native.c
new file mode 100644
index 000000000..0b5e71890
--- /dev/null
+++ b/meson/test cases/java/9 jdk/lib/native.c
@@ -0,0 +1,11 @@
+#include <jni.h>
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ return JNI_VERSION_1_8;
+}
+
+JNIEXPORT void JNICALL
+JNI_OnUnload(JavaVM *vm, void *reserved)
+{}
diff --git a/meson/test cases/java/9 jdk/meson.build b/meson/test cases/java/9 jdk/meson.build
new file mode 100644
index 000000000..310ba5e2a
--- /dev/null
+++ b/meson/test cases/java/9 jdk/meson.build
@@ -0,0 +1,18 @@
+project('jdkjava', ['c', 'java'])
+
+if build_machine.system() == 'cygwin'
+ error('MESON_SKIP_TEST: cygwin test failures')
+endif
+
+if build_machine.system() == 'windows' and build_machine.cpu_family() == 'x86'
+ error('MESON_SKIP_TEST: failing builds on 32bit Windows because a 32bit JDK isn not available in the Azure Pipelines Windows images')
+endif
+
+fs = import('fs')
+
+java = find_program('java')
+
+jdk = dependency('jdk', version : '>=1.8')
+
+subdir('lib')
+subdir('src')
diff --git a/meson/test cases/java/9 jdk/src/com/mesonbuild/JdkTest.java b/meson/test cases/java/9 jdk/src/com/mesonbuild/JdkTest.java
new file mode 100644
index 000000000..35c47cef8
--- /dev/null
+++ b/meson/test cases/java/9 jdk/src/com/mesonbuild/JdkTest.java
@@ -0,0 +1,15 @@
+package com.mesonbuild;
+
+public final class JdkTest {
+ private static native int jdk_test();
+
+ public static void main(String[] args) {
+ if (jdk_test() != 0xdeadbeef) {
+ throw new RuntimeException("jdk_test() did not return 0");
+ }
+ }
+
+ static {
+ System.loadLibrary("jdkjava");
+ }
+}
diff --git a/meson/test cases/java/9 jdk/src/meson.build b/meson/test cases/java/9 jdk/src/meson.build
new file mode 100644
index 000000000..d1b9ee31c
--- /dev/null
+++ b/meson/test cases/java/9 jdk/src/meson.build
@@ -0,0 +1,17 @@
+jdkjar = jar(
+ 'jdkjar',
+ 'com' / 'mesonbuild' / 'JdkTest.java',
+ main_class : 'com.mesonbuild.JdkTest',
+)
+
+test(
+ 'jdktest',
+ java,
+ args: [
+ '-Djava.library.path=@0@'.format(fs.parent(jdkjava.full_path())),
+ '-jar',
+ jdkjar,
+ ],
+ protocol : 'exitcode',
+ depends : [jdkjava],
+)