Put testsuite in its own directory

This commit is contained in:
ktkk 2026-07-06 11:28:58 +00:00
parent 0cf25ebaf4
commit 114b9b099c
16 changed files with 107 additions and 0 deletions

View file

@ -19,6 +19,8 @@
zls zls
javaPackages.compiler.openjdk25 javaPackages.compiler.openjdk25
jdt-language-server jdt-language-server
kotlin
kotlin-language-server
]; ];
buildInputs = with pkgs; []; buildInputs = with pkgs; [];

3
testsuite/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
*.class
!Object.class
META-INF

View 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 {
}

View file

@ -0,0 +1,6 @@
class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}

View file

@ -1,5 +1,6 @@
import java.util.function.Supplier; import java.util.function.Supplier;
@CustomAttribute
public class Main implements Runnable, Supplier<Integer>, Interface { public class Main implements Runnable, Supplier<Integer>, Interface {
private static final String name = "John"; private static final String name = "John";
private static final int number = 42; private static final int number = 42;

View 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;
}
}

Binary file not shown.

View file

@ -0,0 +1,12 @@
fun main() {
println("Hello, world!")
Test().apply {
test = true
}
}
class Test {
var test: Boolean = false
}

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
javac -g -d outDir --module-source-path simple-modules $(find simple-modules -name "*.java")

View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
java --module-path outDir -m main.app/dev.katkak.modules.main.MainApp

View file

@ -0,0 +1,6 @@
package dev.katkak.modules.hello;
public interface HelloInterface {
void sayHello();
}

View file

@ -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!");
}
}

View file

@ -0,0 +1,6 @@
module hello.modules {
exports dev.katkak.modules.hello;
provides dev.katkak.modules.hello.HelloInterface with dev.katkak.modules.hello.HelloModules;
}

View file

@ -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();
}
}

View file

@ -0,0 +1,6 @@
module main.app {
requires hello.modules;
uses dev.katkak.modules.hello.HelloInterface;
}