diff --git a/CedarJava/build.gradle b/CedarJava/build.gradle index 61c7311..719e1fa 100644 --- a/CedarJava/build.gradle +++ b/CedarJava/build.gradle @@ -227,6 +227,16 @@ test { } } +compileTestJava { + sourceCompatibility = "17" + targetCompatibility = "17" +} + +compileJava { + sourceCompatibility = "1.8" + targetCompatibility = "1.8" +} + tasks.named('build') { dependsOn('uberJar') } diff --git a/CedarJava/src/main/java/com/cedarpolicy/model/SourceLocation.java b/CedarJava/src/main/java/com/cedarpolicy/model/SourceLocation.java index 2947c28..48c6ff8 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/model/SourceLocation.java +++ b/CedarJava/src/main/java/com/cedarpolicy/model/SourceLocation.java @@ -39,7 +39,7 @@ public boolean equals(final Object lhs) { return false; } - final var sl = (SourceLocation) lhs; + final SourceLocation sl = (SourceLocation) lhs; return this.start == sl.start && this.end == sl.end; } diff --git a/CedarJava/src/main/java/com/cedarpolicy/model/policy/Policy.java b/CedarJava/src/main/java/com/cedarpolicy/model/policy/Policy.java index 3fdac94..2f58c76 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/model/policy/Policy.java +++ b/CedarJava/src/main/java/com/cedarpolicy/model/policy/Policy.java @@ -86,17 +86,17 @@ public String toJson() throws InternalException, NullPointerException { } public static Policy fromJson(String policyId, String policyJson) throws InternalException, NullPointerException { - var policyText = fromJsonJni(policyJson); + String policyText = fromJsonJni(policyJson); return new Policy(policyText, policyId); } public static Policy parseStaticPolicy(String policyStr) throws InternalException, NullPointerException { - var policyText = parsePolicyJni(policyStr); + String policyText = parsePolicyJni(policyStr); return new Policy(policyText, null); } public static Policy parsePolicyTemplate(String templateStr) throws InternalException, NullPointerException { - var templateText = parsePolicyTemplateJni(templateStr); + String templateText = parsePolicyTemplateJni(templateStr); return new Policy(templateText, null); } diff --git a/CedarJava/src/main/java/com/cedarpolicy/serializer/JsonEUID.java b/CedarJava/src/main/java/com/cedarpolicy/serializer/JsonEUID.java index 0179ac2..194beb9 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/serializer/JsonEUID.java +++ b/CedarJava/src/main/java/com/cedarpolicy/serializer/JsonEUID.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.cedarpolicy.value.EntityUID; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.util.Optional; /** Represent JSON format of Entity Unique Identifier. */ public class JsonEUID { @@ -36,7 +37,7 @@ public class JsonEUID { @Override public String toString() { try { - var mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException("Internal invariant violated, json encoding failed: " + e.toString()); @@ -55,9 +56,9 @@ public JsonEUID(String type, String id) { @SuppressFBWarnings("CT_CONSTRUCTOR_THROW") public JsonEUID(String src) throws InvalidEUIDException { - var o = EntityUID.parse(src); + Optional o = EntityUID.parse(src); if (o.isPresent()) { - var x = o.get().asJson(); + JsonEUID x = o.get().asJson(); this.type = x.type; this.id = x.id; } else { diff --git a/CedarJava/src/main/java/com/cedarpolicy/serializer/ValueDeserializer.java b/CedarJava/src/main/java/com/cedarpolicy/serializer/ValueDeserializer.java index ca9e748..b2cf656 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/serializer/ValueDeserializer.java +++ b/CedarJava/src/main/java/com/cedarpolicy/serializer/ValueDeserializer.java @@ -37,6 +37,7 @@ import java.io.IOException; import java.util.Iterator; import java.util.Map; +import java.util.Optional; /** Deserialize Json to Value. This is mostly an implementation detail, but you may need to modify it if you extend the * `Value` class. */ @@ -95,12 +96,12 @@ public Value deserialize(JsonParser parser, DeserializationContext context) thro numFields++; } if (numFields == 2) { - var id = new EntityIdentifier(val.get("id").textValue()); - var type = EntityTypeName.parse(val.get("type").textValue()); + EntityIdentifier id = new EntityIdentifier(val.get("id").textValue()); + Optional type = EntityTypeName.parse(val.get("type").textValue()); if (type.isPresent()) { return new EntityUID(type.get(), id); } else { - var msg = "Invalid Entity Type" + val.get("type").textValue(); + String msg = "Invalid Entity Type" + val.get("type").textValue(); throw new InvalidValueDeserializationException(parser, msg, node.asToken(), Map.class); } } diff --git a/CedarJava/src/main/java/com/cedarpolicy/value/EntityIdentifier.java b/CedarJava/src/main/java/com/cedarpolicy/value/EntityIdentifier.java index 7d88e02..dcfbdfc 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/value/EntityIdentifier.java +++ b/CedarJava/src/main/java/com/cedarpolicy/value/EntityIdentifier.java @@ -59,7 +59,7 @@ public boolean equals(Object o) { return false; } else { try { - var rhs = (EntityIdentifier) o; + EntityIdentifier rhs = (EntityIdentifier) o; return this.id.equals(rhs.id); } catch (ClassCastException e) { return false; diff --git a/CedarJava/src/main/java/com/cedarpolicy/value/EntityTypeName.java b/CedarJava/src/main/java/com/cedarpolicy/value/EntityTypeName.java index e0f4c30..70bb011 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/value/EntityTypeName.java +++ b/CedarJava/src/main/java/com/cedarpolicy/value/EntityTypeName.java @@ -114,7 +114,7 @@ public boolean equals(Object rhs) { return true; } try { - var rhsTypename = (EntityTypeName) rhs; + EntityTypeName rhsTypename = (EntityTypeName) rhs; return basename.equals(rhsTypename.basename) && namespace.equals(rhsTypename.namespace); } catch (ClassCastException e) { return false; diff --git a/CedarJava/src/main/java/com/cedarpolicy/value/EntityUID.java b/CedarJava/src/main/java/com/cedarpolicy/value/EntityUID.java index 3fea1ce..7ce53b0 100644 --- a/CedarJava/src/main/java/com/cedarpolicy/value/EntityUID.java +++ b/CedarJava/src/main/java/com/cedarpolicy/value/EntityUID.java @@ -87,7 +87,7 @@ public boolean equals(Object o) { return true; } else { try { - var rhs = (EntityUID) o; + EntityUID rhs = (EntityUID) o; return this.type.equals(rhs.type) && this.id.equals(rhs.id); } catch (ClassCastException e) { return false; @@ -122,4 +122,3 @@ public static Optional parseFromJson(JsonEUID euid) { private static native String getEUIDRepr(EntityTypeName type, EntityIdentifier id); } -