Skip to content

Commit 8a746b5

Browse files
committed
chore: java module import
1 parent 449d2ba commit 8a746b5

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// import module java.base;
2+
13
void main(String[] args) {
2-
System.out.println("Java Main!");
4+
var s = readln("Java > ");
5+
println("Hello, " + s);
36
}

meta/scripts/JavaSingleFile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env java --enable-preview --source 24
22

33
void main() {
4-
System.out.printf("Hello Java %s%n", System.getProperty("java.version"));
4+
println("Hello Java " + System.getProperty("java.version"));
55
}

meta/scripts/jrtserver

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ void main() {
1111
var jrtFS = FileSystems.getFileSystem(URI.create("jrt:/"));
1212
// Paths.get(URI.create("jrt:/"))
1313
var modules = jrtFS.getPath("/modules");
14-
var fileServer = SimpleFileServer.createFileServer(
15-
new InetSocketAddress(8080),
16-
modules,
17-
OutputLevel.VERBOSE);
18-
System.out.printf("Visit http://localhost:%d/ to see the file server!%n", fileServer.getAddress().getPort());
14+
var fileServer = SimpleFileServer.createFileServer(new InetSocketAddress(8080), modules, OutputLevel.VERBOSE);
15+
println("Visit http://localhost:" + fileServer.getAddress().getPort() + "/ to see the file server!%n");
1916
fileServer.start();
2017
}

shared/src/jvmMain/java/dev/suresh/DOP.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
import java.util.concurrent.CompletableFuture;
99

1010
import static dev.suresh.Expr.eval;
11+
import static java.io.IO.println;
1112
import static java.lang.System.out;
1213
import static java.util.Objects.requireNonNull;
1314

1415
public class DOP {
15-
16-
void main() throws Exception {
17-
DOP.run();
18-
}
19-
2016
public static void run() throws Exception {
2117
record Person(String name, int age) {
2218
}
@@ -35,7 +31,7 @@ record Person(String name, int age) {
3531
END
3632
""".formatted(new Person("Foo", 40));
3733
future.complete(textBlock);
38-
out.println(future.get());
34+
println(future.get());
3935

4036
stringTemplates();
4137
amberReflections();
@@ -66,7 +62,7 @@ private static <T> void print(Name<T> name) {
6662
case FullName(var first, var last) -> "%s, %s".formatted(first, last);
6763
default -> "Invalid name";
6864
};
69-
out.println(result);
65+
println(result);
7066

7167
if (name instanceof FullName<?> f) {
7268
out.printf("%s, %s%n", f.firstName(), f.lastName());
@@ -94,7 +90,7 @@ private static void amberReflections() {
9490
if (permittedSubclass.isRecord()) {
9591
out.printf("%s record components are,%n", permittedSubclass.getSimpleName());
9692
for (RecordComponent rc : permittedSubclass.getRecordComponents()) {
97-
out.println(rc);
93+
out.print(rc);
9894
}
9995
}
10096
}
@@ -136,7 +132,7 @@ record Lang(String name, int year) implements Serializable {
136132
};
137133

138134
out.printf("Deserialized record: %s%n", rec);
139-
out.println(result);
135+
println(result);
140136
}
141137
}
142138

0 commit comments

Comments
 (0)