summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-07-31 11:11:18 +0100
committerMichael Williamson <mike@zwobble.org>2026-07-31 11:11:18 +0100
commit20f60d8b72a27655abef227d3a213946d61c2370 (patch)
tree577626254a3af316e4eab222e3b2ce8ede2e62e2
parentaec4977f6c8b0d71183d89f99e1eacb06bbd493b (diff)
Make all Java classes final
-rw-r--r--src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java12
2 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java
index 7af7e01..6c7410e 100644
--- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java
+++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriter.java
@@ -88,7 +88,7 @@ public class JavaWriter implements AutoCloseable {
private void writeClassDeclaration(JavaClassDeclaration classDeclaration) throws IOException {
writeDocComment(classDeclaration.docComment());
- this.writer.write("public class ");
+ this.writer.write("public final class ");
this.writeIdentifier(classDeclaration.name());
this.writer.write(" ");
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
index 9b16328..fe5fa81 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/java/JavaWriterTests.java
@@ -37,7 +37,7 @@ public class JavaWriterTests {
// Custom area start: com.example.shapes.Rectangle imports
// Custom area end: com.example.shapes.Rectangle imports
- public class Rectangle {
+ public final class Rectangle {
// Custom area start: com.example.shapes.Rectangle body
// Custom area end: com.example.shapes.Rectangle body
}
@@ -61,7 +61,7 @@ public class JavaWriterTests {
var string = write(writer -> writer.writeTypeDeclaration(java));
assertThat(string, equalTo("""
- public class Rectangle {
+ public final class Rectangle {
// Custom area start: Rectangle body
// Custom area end: Rectangle body
}"""
@@ -85,7 +85,7 @@ public class JavaWriterTests {
var string = write(writer -> writer.writeTypeDeclaration(java));
assertThat(string, equalTo("""
- public class Rectangle implements com.example.Shape {
+ public final class Rectangle implements com.example.Shape {
// Custom area start: Rectangle body
// Custom area end: Rectangle body
}"""
@@ -107,7 +107,7 @@ public class JavaWriterTests {
var string = write(writer -> writer.writeTypeDeclaration(java));
assertThat(string, equalTo("""
- public class Rectangle implements com.example.Shape, com.example.Drawable {
+ public final class Rectangle implements com.example.Shape, com.example.Drawable {
// Custom area start: Rectangle body
// Custom area end: Rectangle body
}"""
@@ -141,7 +141,7 @@ public class JavaWriterTests {
var string = write(writer -> writer.writeTypeDeclaration(java));
assertThat(string, equalTo("""
- public class Rectangle {
+ public final class Rectangle {
public void a() {
}
@@ -167,7 +167,7 @@ public class JavaWriterTests {
assertThat(string, equalTo("""
/// A 2D point.
- public class Point {
+ public final class Point {
// Custom area start: Point body
// Custom area end: Point body
}"""