Skip to content

Commit 1cb381e

Browse files
committed
Consistent deprecation markers on JDK 9
1 parent 08c2fd4 commit 1cb381e

File tree

7 files changed

+35
-29
lines changed

7 files changed

+35
-29
lines changed

spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3543,6 +3543,7 @@ public interface CustomMap<K, V> extends Map<K, V> {
35433543
}
35443544

35453545

3546+
@SuppressWarnings("serial")
35463547
public static class CustomHashMap<K, V> extends LinkedHashMap<K, V> implements CustomMap<K, V> {
35473548
}
35483549

@@ -3551,6 +3552,7 @@ public interface CustomSet<E> extends Set<E> {
35513552
}
35523553

35533554

3555+
@SuppressWarnings("serial")
35543556
public static class CustomHashSet<E> extends LinkedHashSet<E> implements CustomSet<E> {
35553557
}
35563558

spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@
3333
import org.w3c.dom.Node;
3434
import org.xml.sax.InputSource;
3535
import org.xml.sax.XMLReader;
36-
import org.xml.sax.helpers.XMLReaderFactory;
3736
import org.xmlunit.util.Predicate;
3837

3938
import static org.junit.Assert.*;
@@ -59,12 +58,14 @@ public abstract class AbstractStaxHandlerTestCase {
5958
private static final Predicate<Node> nodeFilter = (n -> n.getNodeType() != Node.COMMENT_NODE &&
6059
n.getNodeType() != Node.DOCUMENT_TYPE_NODE && n.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE);
6160

61+
6262
private XMLReader xmlReader;
6363

6464

6565
@Before
66+
@SuppressWarnings("deprecation") // on JDK 9
6667
public void createXMLReader() throws Exception {
67-
xmlReader = XMLReaderFactory.createXMLReader();
68+
xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
6869
}
6970

7071

spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@
3737
import org.xml.sax.XMLReader;
3838
import org.xml.sax.ext.LexicalHandler;
3939
import org.xml.sax.helpers.AttributesImpl;
40-
import org.xml.sax.helpers.XMLReaderFactory;
4140

4241
import org.springframework.core.io.ClassPathResource;
4342
import org.springframework.core.io.Resource;
@@ -47,6 +46,9 @@
4746
import static org.junit.Assert.*;
4847
import static org.mockito.BDDMockito.*;
4948

49+
/**
50+
* @author Arjen Poutsma
51+
*/
5052
public abstract class AbstractStaxXMLReaderTestCase {
5153

5254
protected static XMLInputFactory inputFactory;
@@ -57,9 +59,10 @@ public abstract class AbstractStaxXMLReaderTestCase {
5759

5860

5961
@Before
62+
@SuppressWarnings("deprecation") // on JDK 9
6063
public void setUp() throws Exception {
6164
inputFactory = XMLInputFactory.newInstance();
62-
standardReader = XMLReaderFactory.createXMLReader();
65+
standardReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
6366
standardContentHandler = mockContentHandler();
6467
standardReader.setContentHandler(standardContentHandler);
6568
}

spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,21 +16,19 @@
1616

1717
package org.springframework.util.xml;
1818

19+
import java.io.StringReader;
20+
import javax.xml.parsers.DocumentBuilder;
21+
import javax.xml.parsers.DocumentBuilderFactory;
22+
1923
import org.junit.Before;
2024
import org.junit.Test;
2125
import org.w3c.dom.Document;
2226
import org.w3c.dom.Element;
2327
import org.xml.sax.InputSource;
2428
import org.xml.sax.XMLReader;
25-
import org.xml.sax.helpers.XMLReaderFactory;
26-
27-
import javax.xml.parsers.DocumentBuilder;
28-
import javax.xml.parsers.DocumentBuilderFactory;
29-
import java.io.StringReader;
30-
31-
import static org.junit.Assert.assertThat;
32-
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
3329

30+
import static org.junit.Assert.*;
31+
import static org.xmlunit.matchers.CompareMatcher.*;
3432

3533
/**
3634
* Unit tests for {@link DomContentHandler}.
@@ -49,6 +47,7 @@ public class DomContentHandlerTests {
4947
private static final String XML_2_SNIPPET =
5048
"<?xml version='1.0' encoding='UTF-8'?>" + "<child xmlns='namespace2' />";
5149

50+
5251
private Document expected;
5352

5453
private DomContentHandler handler;
@@ -59,15 +58,18 @@ public class DomContentHandlerTests {
5958

6059
private DocumentBuilder documentBuilder;
6160

61+
6262
@Before
63+
@SuppressWarnings("deprecation") // on JDK 9
6364
public void setUp() throws Exception {
6465
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
6566
documentBuilderFactory.setNamespaceAware(true);
6667
documentBuilder = documentBuilderFactory.newDocumentBuilder();
6768
result = documentBuilder.newDocument();
68-
xmlReader = XMLReaderFactory.createXMLReader();
69+
xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
6970
}
7071

72+
7173
@Test
7274
public void contentHandlerDocumentNamespacePrefixes() throws Exception {
7375
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
@@ -96,7 +98,6 @@ public void contentHandlerElement() throws Exception {
9698
xmlReader.setContentHandler(handler);
9799
xmlReader.parse(new InputSource(new StringReader(XML_2_SNIPPET)));
98100
assertThat("Invalid result", result, isSimilarTo(expected));
99-
100101
}
101102

102-
}
103+
}

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@
100100
import org.springframework.util.xml.StaxUtils;
101101

102102
/**
103-
* Implementation of the {@code GenericMarshaller} interface for JAXB 2.1/2.2,
104-
* as included in JDK 6 update 4+ and Java 7/8.
103+
* Implementation of the {@code GenericMarshaller} interface for JAXB 2.2.
105104
*
106105
* <p>The typical usage will be to set either the "contextPath" or the "classesToBeBound"
107106
* property on this bean, possibly customize the marshaller and unmarshaller by setting
@@ -544,6 +543,7 @@ private JAXBContext createJaxbContextFromPackages() throws JAXBException {
544543
}
545544
}
546545

546+
@SuppressWarnings("deprecation") // on JDK 9
547547
private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IOException, SAXException {
548548
if (logger.isDebugEnabled()) {
549549
logger.debug("Setting validation schema to " +
@@ -588,7 +588,6 @@ public boolean supports(Type genericType) {
588588
supportsInternal(classArgument, false));
589589
}
590590
else if (typeArgument instanceof GenericArrayType) {
591-
// Only on JDK 6 - see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784
592591
GenericArrayType arrayType = (GenericArrayType) typeArgument;
593592
return (Byte.TYPE == arrayType.getGenericComponentType());
594593
}
@@ -773,9 +772,8 @@ else if (this.mappedClass != null) {
773772
}
774773
catch (NullPointerException ex) {
775774
if (!isSupportDtd()) {
776-
throw new UnmarshallingFailureException("NPE while unmarshalling. " +
777-
"This can happen on JDK 1.6 due to the presence of DTD " +
778-
"declarations, which are disabled.", ex);
775+
throw new UnmarshallingFailureException("NPE while unmarshalling: " +
776+
"This can happen due to the presence of DTD declarations which are disabled.", ex);
779777
}
780778
throw ex;
781779
}
@@ -804,6 +802,7 @@ protected Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, Source staxS
804802
}
805803
}
806804

805+
@SuppressWarnings("deprecation") // on JDK 9
807806
private Source processSource(Source source) {
808807
if (StaxUtils.isStaxSource(source) || source instanceof DOMSource) {
809808
return source;

spring-oxm/src/main/java/org/springframework/oxm/support/AbstractMarshaller.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ protected DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory)
183183
* @return the XMLReader
184184
* @throws SAXException if thrown by JAXP methods
185185
*/
186+
@SuppressWarnings("deprecation") // on JDK 9
186187
protected XMLReader createXmlReader() throws SAXException {
187188
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
188189
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());

spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -171,6 +171,7 @@ public void withSameIntegerInstanceTwice() {
171171
}
172172

173173
@Test
174+
@SuppressWarnings("deprecation") // on JDK 9
174175
public void withEquivalentIntegerInstanceTwice() {
175176
Collection<Integer> col = new ArrayList<>(2);
176177
col.add(new Integer(5));
@@ -273,10 +274,8 @@ public void exceptionTranslationWithTranslation() {
273274

274275
public static class MapPersistenceExceptionTranslator implements PersistenceExceptionTranslator {
275276

276-
/**
277-
* in to out
278-
*/
279-
private Map<RuntimeException,RuntimeException> translations = new HashMap<>();
277+
// in to out
278+
private final Map<RuntimeException, RuntimeException> translations = new HashMap<>();
280279

281280
public void addTranslation(RuntimeException in, RuntimeException out) {
282281
this.translations.put(in, out);

0 commit comments

Comments
 (0)