Skip to content

Commit cd2f2bc

Browse files
committed
fix(java8): restore JDK 8 compatibility by removing Java 9–11 APIs
- ContractLoader: replace Optional.isEmpty() with !isPresent(). - DocumentProcessingResult: - replace List.copyOf(...) with new ArrayList<>(...) defensive copy. - replace List.of() with Collections.emptyList(). - keep immutability via Collections.unmodifiableList(new ArrayList<>(...)). - No behavioral changes; only API substitutions for JDK 8.
1 parent c10691f commit cd2f2bc

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/blue/language/processor/ContractLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ ContractBundle load(Node scopeNode, String scopePath) {
4646
if (contract instanceof ChannelContract) {
4747
ChannelContract channel = (ChannelContract) contract;
4848
if (!ProcessorContractConstants.isProcessorManagedChannel(channel)
49-
&& registry.lookupChannel(channel.getClass()).isEmpty()) {
49+
&& !registry.lookupChannel(channel.getClass()).isPresent()) {
5050
throw new MustUnderstandFailureException(
5151
"Unsupported contract type: " + channel.getClass().getName());
5252
}
5353
builder.addChannel(key, channel);
5454
} else if (contract instanceof HandlerContract) {
5555
HandlerContract handler = (HandlerContract) contract;
56-
if (registry.lookupHandler(handler.getClass()).isEmpty()) {
56+
if (!registry.lookupHandler(handler.getClass()).isPresent()) {
5757
throw new MustUnderstandFailureException(
5858
"Unsupported contract type: " + handler.getClass().getName());
5959
}

src/main/java/blue/language/processor/DocumentProcessingResult.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import blue.language.model.Node;
44

5+
import java.util.ArrayList;
56
import java.util.Collections;
67
import java.util.List;
78
import java.util.Objects;
@@ -18,12 +19,12 @@ public final class DocumentProcessingResult {
1819
private final String failureReason;
1920

2021
private DocumentProcessingResult(Node document,
21-
List<Node> triggeredEvents,
22-
long totalGas,
23-
boolean capabilityFailure,
24-
String failureReason) {
22+
List<Node> triggeredEvents,
23+
long totalGas,
24+
boolean capabilityFailure,
25+
String failureReason) {
2526
this.document = document;
26-
this.triggeredEvents = Collections.unmodifiableList(triggeredEvents);
27+
this.triggeredEvents = Collections.unmodifiableList(new ArrayList<>(triggeredEvents));
2728
this.totalGas = totalGas;
2829
this.capabilityFailure = capabilityFailure;
2930
this.failureReason = failureReason;
@@ -32,12 +33,12 @@ private DocumentProcessingResult(Node document,
3233
public static DocumentProcessingResult of(Node document, List<Node> triggeredEvents, long totalGas) {
3334
Objects.requireNonNull(document, "document");
3435
Objects.requireNonNull(triggeredEvents, "triggeredEvents");
35-
return new DocumentProcessingResult(document, List.copyOf(triggeredEvents), totalGas, false, null);
36+
return new DocumentProcessingResult(document, new ArrayList<>(triggeredEvents), totalGas, false, null);
3637
}
3738

3839
public static DocumentProcessingResult capabilityFailure(Node document, String reason) {
3940
Objects.requireNonNull(document, "document");
40-
return new DocumentProcessingResult(document, List.of(), 0L, true, reason);
41+
return new DocumentProcessingResult(document, Collections.emptyList(), 0L, true, reason);
4142
}
4243

4344
public Node document() {
@@ -59,4 +60,4 @@ public boolean capabilityFailure() {
5960
public String failureReason() {
6061
return failureReason;
6162
}
62-
}
63+
}

0 commit comments

Comments
 (0)