Put testsuite in its own directory
This commit is contained in:
parent
0cf25ebaf4
commit
114b9b099c
16 changed files with 107 additions and 0 deletions
|
|
@ -19,6 +19,8 @@
|
|||
zls
|
||||
javaPackages.compiler.openjdk25
|
||||
jdt-language-server
|
||||
kotlin
|
||||
kotlin-language-server
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [];
|
||||
|
|
|
|||
3
testsuite/.gitignore
vendored
Normal file
3
testsuite/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*.class
|
||||
!Object.class
|
||||
META-INF
|
||||
10
testsuite/classes/java/CustomAttribute.java
Normal file
10
testsuite/classes/java/CustomAttribute.java
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface CustomAttribute {
|
||||
}
|
||||
|
||||
6
testsuite/classes/java/Hello.java
Normal file
6
testsuite/classes/java/Hello.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Hello {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import java.util.function.Supplier;
|
||||
|
||||
@CustomAttribute
|
||||
public class Main implements Runnable, Supplier<Integer>, Interface {
|
||||
private static final String name = "John";
|
||||
private static final int number = 42;
|
||||
22
testsuite/classes/java/MultiThreading.java
Normal file
22
testsuite/classes/java/MultiThreading.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class MultiThreading {
|
||||
private int number = 0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
final var multiThreading = new MultiThreading();
|
||||
|
||||
final var service = Executors.newFixedThreadPool(3);
|
||||
IntStream.range(0, 1000)
|
||||
.forEach(count -> service.submit(multiThreading::increment));
|
||||
service.awaitTermination(1000, TimeUnit.MILLISECONDS);
|
||||
|
||||
System.out.println(multiThreading.number);
|
||||
}
|
||||
|
||||
public synchronized void increment() {
|
||||
number += 1;
|
||||
}
|
||||
}
|
||||
BIN
testsuite/classes/java/Object.class
Normal file
BIN
testsuite/classes/java/Object.class
Normal file
Binary file not shown.
12
testsuite/classes/kotlin/Main.kt
Normal file
12
testsuite/classes/kotlin/Main.kt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fun main() {
|
||||
println("Hello, world!")
|
||||
|
||||
Test().apply {
|
||||
test = true
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
var test: Boolean = false
|
||||
}
|
||||
|
||||
2
testsuite/modules/compile-simple-modules.sh
Executable file
2
testsuite/modules/compile-simple-modules.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
javac -g -d outDir --module-source-path simple-modules $(find simple-modules -name "*.java")
|
||||
2
testsuite/modules/run-simple-module-app.sh
Executable file
2
testsuite/modules/run-simple-module-app.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
java --module-path outDir -m main.app/dev.katkak.modules.main.MainApp
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package dev.katkak.modules.hello;
|
||||
|
||||
public interface HelloInterface {
|
||||
void sayHello();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package dev.katkak.modules.hello;
|
||||
|
||||
public class HelloModules implements HelloInterface {
|
||||
public static void doSomething() {
|
||||
System.out.println("Hello, Modules!");
|
||||
}
|
||||
|
||||
public void sayHello() {
|
||||
System.out.println("Hello!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
module hello.modules {
|
||||
exports dev.katkak.modules.hello;
|
||||
|
||||
provides dev.katkak.modules.hello.HelloInterface with dev.katkak.modules.hello.HelloModules;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package dev.katkak.modules.main;
|
||||
|
||||
import dev.katkak.modules.hello.HelloModules;
|
||||
import dev.katkak.modules.hello.HelloInterface;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public class MainApp {
|
||||
public static void main(String[] args) {
|
||||
HelloModules.doSomething();
|
||||
|
||||
final var services = ServiceLoader.load(HelloInterface.class);
|
||||
final var service = services.iterator().next();
|
||||
service.sayHello();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
module main.app {
|
||||
requires hello.modules;
|
||||
|
||||
uses dev.katkak.modules.hello.HelloInterface;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue