diff --git a/.travis.yml b/.travis.yml index 0eadda7688..909b77aa12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: java # Configure the build to use Oracle JDK 9 jdk: - - openjdk11 + - openjdk21 # Install the Ant JUnit package, which is missing from the Travis CI environment. See the Travis documentation: https://docs.travis-ci.com/user/installing-dependencies/#Adding-APT-Packages addons: diff --git a/nbproject/project.properties b/nbproject/project.properties index fab181db51..de8a7bdfc9 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -56,8 +56,8 @@ javac.modulepath= javac.processormodulepath= javac.processorpath=\ ${javac.classpath} -javac.source=11 -javac.target=11 +javac.source=21 +javac.target=21 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/release-build.properties b/release-build.properties index cde1c0e4de..689b787445 100644 --- a/release-build.properties +++ b/release-build.properties @@ -38,7 +38,7 @@ worldwind.classes.dir=${worldwind.build.dir}/classes worldwind.doc.dir=${worldwind.build.dir}/doc worldwind.jar.dir=${worldwind.build.dir}/jar worldwind.test.results.dir=${worldwind.build.dir}/test-results -worldwind.jdk=11 +worldwind.jdk=21 #worldwind.exclude.jackson=true # MIL-STD-2525 package build properties diff --git a/release-build.xml b/release-build.xml index 9810ad732d..7948d88789 100644 --- a/release-build.xml +++ b/release-build.xml @@ -126,7 +126,7 @@ - + diff --git a/src/gov/nasa/worldwind/wms/Capabilities.java b/src/gov/nasa/worldwind/wms/Capabilities.java index 3d81fe5c6f..8f89b0a74b 100644 --- a/src/gov/nasa/worldwind/wms/Capabilities.java +++ b/src/gov/nasa/worldwind/wms/Capabilities.java @@ -83,13 +83,8 @@ public static Capabilities retrieve(URI uri, String service, Integer connectTime CapabilitiesRequest req = new CapabilitiesRequest(uri, service); URL capsURL = req.getUri().toURL(); - URLRetriever retriever = URLRetriever.createRetriever(capsURL, new RetrievalPostProcessor() - { - public ByteBuffer run(Retriever retriever) - { - return retriever.getBuffer(); - } - }); + URLRetriever retriever = URLRetriever.createRetriever(capsURL, + (Retriever r) -> r.getBuffer()); if (retriever == null) { @@ -281,7 +276,7 @@ protected String[] getUniqueText(Element context, String path) if (strings == null) return null; - ArrayList sarl = new ArrayList(); + ArrayList sarl = new ArrayList<>(); for (String s : strings) { if (!sarl.contains(s)) @@ -300,7 +295,7 @@ protected Element getElement(Element context, String path) if (node == null) return null; - return node instanceof Element ? (Element) node : null; + return node instanceof Element e ? e : null; } catch (XPathExpressionException e) { @@ -321,8 +316,8 @@ protected Element[] getElements(Element context, String path) for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); - if (node instanceof Element) - elements[i] = (Element) node; + if (node instanceof Element e) + elements[i] = e; } return elements; } @@ -338,7 +333,7 @@ protected Element[] getUniqueElements(Element context, String path, String uniqu if (elements == null) return null; - HashMap styles = new HashMap(); + HashMap styles = new HashMap<>(); for (Element e : elements) { String name = this.getText(e, uniqueTag); @@ -349,8 +344,8 @@ protected Element[] getUniqueElements(Element context, String path, String uniqu return styles.values().toArray(new Element[1]); } - private HashMap namedLayerElements = new HashMap(); - private HashMap namedLayers = new HashMap(); + private HashMap namedLayerElements = new HashMap<>(); + private HashMap namedLayers = new HashMap<>(); private void fillLayerList() { @@ -643,7 +638,7 @@ public Element getLayer() protected static class Layer { - protected HashMap styleElements = new HashMap(); + protected HashMap styleElements = new HashMap<>(); protected final Element element; protected Layer layer; protected String name; @@ -725,8 +720,8 @@ public Element[] getLayerDimensions(Element layer) if (dims == null || dims.length == 0) return null; - ArrayList uniqueDims = new ArrayList(); - ArrayList dimNames = new ArrayList(); + ArrayList uniqueDims = new ArrayList<>(); + ArrayList dimNames = new ArrayList<>(); for (Element e : dims) { // Filter out dimensions with same name. @@ -749,8 +744,8 @@ public Element[] getLayerExtents(Element layer) if (extents == null || extents.length == 0) return null; - ArrayList uniqueExtents = new ArrayList(); - ArrayList extentNames = new ArrayList(); + ArrayList uniqueExtents = new ArrayList<>(); + ArrayList extentNames = new ArrayList<>(); for (Element e : extents) { // Filter out dimensions with same name. @@ -846,7 +841,7 @@ public Element[] getLayerStyles(Element layerElement) if (styleElements == null) return null; - layer.styleElements = new HashMap(); + layer.styleElements = new HashMap<>(); for (Element se : styleElements) { Style style = new Style(se, layer); @@ -912,7 +907,7 @@ public String getLayerExtremeElevationsMax(Element layer) // ********* Style Items ********* // - protected HashMap styleElements = new HashMap(); + protected HashMap styleElements = new HashMap<>(); protected static class Style { diff --git a/src/gov/nasa/worldwind/wms/CapabilitiesV111.java b/src/gov/nasa/worldwind/wms/CapabilitiesV111.java index d5861df5e8..a24268fa2c 100644 --- a/src/gov/nasa/worldwind/wms/CapabilitiesV111.java +++ b/src/gov/nasa/worldwind/wms/CapabilitiesV111.java @@ -63,8 +63,8 @@ public BoundingBox[] getLayerBoundingBoxes(Element layer) if (es == null) return null; - ArrayList bboxes = new ArrayList(); - ArrayList crses = new ArrayList(); + ArrayList bboxes = new ArrayList<>(); + ArrayList crses = new ArrayList<>(); for (Element e : es) { diff --git a/src/gov/nasa/worldwind/wms/CapabilitiesV130.java b/src/gov/nasa/worldwind/wms/CapabilitiesV130.java index 43c85042aa..716175d3f1 100644 --- a/src/gov/nasa/worldwind/wms/CapabilitiesV130.java +++ b/src/gov/nasa/worldwind/wms/CapabilitiesV130.java @@ -63,8 +63,8 @@ public BoundingBox[] getLayerBoundingBoxes(Element layer) if (es == null) return null; - ArrayList bboxes = new ArrayList(); - ArrayList crses = new ArrayList(); + ArrayList bboxes = new ArrayList<>(); + ArrayList crses = new ArrayList<>(); for (Element e : es) { diff --git a/src/gov/nasa/worldwind/wms/Request.java b/src/gov/nasa/worldwind/wms/Request.java index fccfb380df..90280619ec 100644 --- a/src/gov/nasa/worldwind/wms/Request.java +++ b/src/gov/nasa/worldwind/wms/Request.java @@ -45,7 +45,7 @@ public abstract class Request // Use a TreeMap to hold the query params so that they'll always be attached to the // URL query string in the same order. This allows a simple string comparison to // determine whether two url strings address the same document. - private TreeMap queryParams = new TreeMap(); + private TreeMap queryParams = new TreeMap<>(); /** Constructs a request for the default service, WMS. */ protected Request() @@ -130,7 +130,7 @@ private void copyParamsTo(Request destinationRequest) for (Map.Entry entry : this.queryParams.entrySet()) { - destinationRequest.setParam((String) ((Map.Entry) entry).getKey(), (String) ((Map.Entry) entry).getValue()); + destinationRequest.setParam(entry.getKey(), entry.getValue()); } } @@ -226,18 +226,18 @@ public URI getUri() throws URISyntaxException private String buildQueryString(String existingQueryString) { - StringBuffer queryString = new StringBuffer(existingQueryString != null ? existingQueryString : ""); + StringBuilder queryString = new StringBuilder(existingQueryString != null ? existingQueryString : ""); if (queryString.length() > 1 && queryString.lastIndexOf("&") != queryString.length() - 1) - queryString = queryString.append("&"); + queryString.append("&"); for (Map.Entry entry : this.queryParams.entrySet()) { - if (((Map.Entry) entry).getKey() != null && ((Map.Entry) entry).getValue() != null) + if (entry.getKey() != null && entry.getValue() != null) { - queryString.append(((Map.Entry) entry).getKey()); + queryString.append(entry.getKey()); queryString.append("="); - queryString.append(((Map.Entry) entry).getValue()); + queryString.append(entry.getValue()); queryString.append("&"); } } diff --git a/src/gov/nasa/worldwind/wms/WMSTiledImageLayer.java b/src/gov/nasa/worldwind/wms/WMSTiledImageLayer.java index 315533bfee..2a4745b1fb 100644 --- a/src/gov/nasa/worldwind/wms/WMSTiledImageLayer.java +++ b/src/gov/nasa/worldwind/wms/WMSTiledImageLayer.java @@ -216,10 +216,10 @@ public URLBuilder(AVList params) public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException { - StringBuffer sb; + StringBuilder sb; if (this.URLTemplate == null) { - sb = new StringBuffer(WWXML.fixGetMapString(tile.getLevel().getService())); + sb = new StringBuilder(WWXML.fixGetMapString(tile.getLevel().getService())); if (!sb.toString().toLowerCase().contains("service=wms")) sb.append("service=WMS"); @@ -236,7 +236,7 @@ public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException } else { - sb = new StringBuffer(this.URLTemplate); + sb = new StringBuilder(this.URLTemplate); } String format = (altImageFormat != null) ? altImageFormat : this.imageFormat; @@ -396,10 +396,10 @@ protected Document createConfigurationDocument(AVList params) public void getRestorableStateForAVPair(String key, Object value, RestorableSupport rs, RestorableSupport.StateObject context) { - if (value instanceof URLBuilder) + if (value instanceof URLBuilder urlBuilder) { - rs.addStateValueAsString(context, "wms.Version", ((URLBuilder) value).wmsVersion); - rs.addStateValueAsString(context, "wms.Crs", ((URLBuilder) value).crs); + rs.addStateValueAsString(context, "wms.Version", urlBuilder.wmsVersion); + rs.addStateValueAsString(context, "wms.Crs", urlBuilder.crs); } else {