Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ if (project.hasProperty('enableSonar')) {

group = 'org.apache.xmlbeans'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
Expand All @@ -72,7 +72,7 @@ ext {
log4jVersion = '2.26.1'
saxonVersion = '13.0'
androidSdkMinimum = '26'
jdkVersion = (project.properties['jdkVersion'] ?: '8') as int
jdkVersion = (project.properties['jdkVersion'] ?: '17') as int
}

def testSchemas = [
Expand Down Expand Up @@ -271,18 +271,12 @@ javadoc {
maxMemory = "1024M"
doFirst {
options {
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
addBooleanOption('html5', true)
}
addBooleanOption('html5', true)
addBooleanOption('Xdoclint:all,-missing', true)
links 'https://poi.apache.org/apidocs/dev/'
if (JavaVersion.current().ordinal() >= JavaVersion.VERSION_23.ordinal()) {
links 'https://docs.oracle.com/en/java/javase/23/docs/api/'
} else {
links 'https://docs.oracle.com/javase/8/docs/api/'
}
links 'https://docs.oracle.com/en/java/javase/17/docs/api/'
links 'https://xmlbeans.apache.org/docs/5.0.0/'
source = "1.8"
source = "17"
}
}
}
Expand All @@ -296,10 +290,10 @@ task compileJava9(type: JavaCompile) {
dependsOn 'compileJava'

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(Math.max(11, jdkVersion))
languageVersion = JavaLanguageVersion.of(jdkVersion)
}
sourceCompatibility = 9
targetCompatibility = 9
sourceCompatibility = 17
targetCompatibility = 17
destinationDirectory = file('build/classes/java9/main/META-INF/versions/9')
source = file('src/main/java9')
classpath = files()
Expand Down Expand Up @@ -685,8 +679,6 @@ forbiddenApis {
// signaturesFiles = files('src/test/resources/forbiddenApis/forbidden-signatures.txt')
ignoreFailures = false
suppressAnnotations = [ 'org.apache.xmlbeans.impl.util.SuppressForbidden' ]
// forbiddenapis bundled signatures max supported version is 14
targetCompatibility = (JavaVersion.VERSION_14.isCompatibleWith(JavaVersion.current()) ? JavaVersion.current() : JavaVersion.VERSION_14)
}

//forbiddenApisMain.onlyIf { false }
Expand Down
22 changes: 11 additions & 11 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
xmlns:mvn="antlib:org.apache.maven.artifact.ant"
xmlns:if="ant:if" xmlns:unless="ant:unless">

<property name="jdk.version.source" value="1.8" description="JDK version of source code"/>
<property name="jdk.version.class" value="1.8" description="JDK version of generated class files"/>
<property name="jdk.version.source" value="17" description="JDK version of source code"/>
<property name="jdk.version.class" value="17" description="JDK version of generated class files"/>
<property name="compile.debug" value="true"/>

<property name="version.base" value="5.5.0-SNAPSHOT"/>
Expand Down Expand Up @@ -313,7 +313,7 @@
</filterchain>
</copy>

<javac release="8"
<javac release="17"
destdir="@{rscDir}"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand Down Expand Up @@ -378,7 +378,7 @@

<mkdir dir="build/classes"/>
<mkdir dir="build/generated-sources"/>
<javac release="8"
<javac release="17"
destdir="build/classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand Down Expand Up @@ -423,7 +423,7 @@
<!-- delete old schema classes -->
<delete dir="build/classes/org/apache/xmlbeans/impl/xb"/>

<javac release="8"
<javac release="17"
destdir="build/classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand All @@ -439,7 +439,7 @@
<classpath refid="maven-plugin"/>
</javac>

<javac release="9"
<javac release="17"
srcdir="${basedir}/src/main/multimodule/java9"
destdir="${basedir}/src/main/multimodule/java9"
includeantruntime="false"
Expand Down Expand Up @@ -549,7 +549,7 @@


<target name="test-compile" depends="process-test-resources" description="Compile test sources and resources">
<javac release="8"
<javac release="17"
destdir="build/test-classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand All @@ -569,7 +569,7 @@
</javac>

<mkdir dir="build/test-syscache/1/classes"/>
<javac release="8"
<javac release="17"
destdir="build/test-syscache/1/classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand All @@ -581,7 +581,7 @@
<classpath location="build/test-syscache/1/generated-resources"/>
</javac>
<mkdir dir="build/test-syscache/2/classes"/>
<javac release="8"
<javac release="17"
destdir="build/test-syscache/2/classes"
debug="${compile.debug}"
debuglevel="lines,vars,source"
Expand Down Expand Up @@ -630,11 +630,11 @@
<delete dir="${javadocs.dir}"/>
<mkdir dir="${javadocs.dir}"/>

<!-- force Java 8 source compatibility - see https://stackoverflow.com/questions/56409697 -->
<!-- force Java 17 source compatibility - see https://stackoverflow.com/questions/56409697 -->
<javadoc sourcepathref="sources"
destdir="${javadocs.dir}"
windowtitle="XMLBeans ${version.base} Documentation"
source="8">
source="17">
<classpath>
<pathelement location="build/classes"/>
<fileset dir="lib/main" includes="*.jar"/>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/xmlbeans/QNameSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ public static QNameSet forArray(QName[] includedQNames) {
* @return the copied QNameSet
*/
public static QNameSet forSpecification(QNameSetSpecification spec) {
if (spec instanceof QNameSet) {
return (QNameSet) spec;
if (spec instanceof QNameSet set) {
return set;
}
return QNameSet.forSets(spec.excludedURIs(), spec.includedURIs(), spec.excludedQNamesInIncludedURIs(), spec.includedQNamesInExcludedURIs());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/xmlbeans/XmlOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1609,8 +1609,8 @@ public void setCompilePartialMethod(Set<BeanMethod> list) {
*/
public int getMaxNumberOfCharsForNumbers() {
Object value = get(XmlOptionsKeys.MAX_NUMBER_CHARS);
if (value instanceof Number) {
return ((Number) value).intValue();
if (value instanceof Number number) {
return number.intValue();
}
return DEFAULT_MAX_NUMBER_CHARS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/xmlbeans/XmlSimpleList.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ public void add(Object o) {
}

private String stringValue(Object o) {
if (o instanceof SimpleValue) {
return ((SimpleValue) o).getStringValue();
if (o instanceof SimpleValue value) {
return value.getStringValue();
}
return o.toString();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/apache/xmlbeans/impl/common/IOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public static void copyCompletely(InputStream input, OutputStream output)
throws IOException {
try {
//if both are file streams, use channel IO
if ((output instanceof FileOutputStream) && (input instanceof FileInputStream)) {
if ((output instanceof FileOutputStream fos) && (input instanceof FileInputStream fis)) {
try {
FileChannel target = ((FileOutputStream) output).getChannel();
FileChannel source = ((FileInputStream) input).getChannel();
FileChannel target = fos.getChannel();
FileChannel source = fis.getChannel();

source.transferTo(0, Integer.MAX_VALUE, target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ void createFieldState(Event e, SchemaType st) {
void remove(Event e) {
// Bubble up key, unique values to keyrefs
for (ConstraintState cs = _next; cs != null; cs = cs._next) {
if (cs instanceof KeyrefState) {
KeyrefState kr = (KeyrefState) cs;
if (cs instanceof KeyrefState kr) {
if (kr._constraint.getReferencedKey() == this._constraint) {
kr.addKeyValues(_values, true);
}
Expand Down Expand Up @@ -345,8 +344,7 @@ void remove(Event e) {
// First check if there are any keys at the same stack level as this
// that may contribute key values to me
for (ConstraintState cs = _next; cs != null && cs != _elementStack._savePoint; cs = cs._next) {
if (cs instanceof SelectorState) {
SelectorState sel = (SelectorState) cs;
if (cs instanceof SelectorState sel) {
if (sel._constraint == _constraint.getReferencedKey()) {
addKeyValues(sel._values, false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/apache/xmlbeans/impl/common/Sax2Dom.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public Sax2Dom() throws ParserConfigurationException
public Sax2Dom(Node root) throws ParserConfigurationException
{
_root = root;
if (root instanceof Document)
if (root instanceof Document document)
{
_document = (Document) root;
_document = document;
}
else if (root != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public final int hashCode() {
public final boolean equals(Object obj) {
if (obj == this) return true;

if (obj instanceof XMLName) {
final XMLName name= (XMLName) obj;

if (obj instanceof XMLName name) {
final String lname = localName;
if (!(lname==null ? name.getLocalName()==null :
lname.equals(name.getLocalName())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
QName name = qnameconfig.getName();
String javaname = qnameconfig.getJavaname();
for (XmlAnySimpleType xmlAnySimpleType : applyto) {
if (xmlAnySimpleType instanceof Qnametargetenum) {
Qnametargetenum a = (Qnametargetenum) xmlAnySimpleType;
if (xmlAnySimpleType instanceof Qnametargetenum a) {
switch (a.getEnumValue().intValue()) {
case Qnametargetenum.INT_TYPE:
_qnameTypeMap.put(name, javaname);
Expand Down Expand Up @@ -170,9 +169,9 @@
result.put("", value);
} else if (key instanceof String && "##any".equals(key)) {
result.put(key, value);
} else if (key instanceof List) {
} else if (key instanceof List<?> list) {
// map uris to value
((List<?>) key).forEach(o -> result.put("##local".equals(o) ? "" : o, value));
list.forEach(o -> result.put("##local".equals(o) ? "" : o, value));
}
}

Expand All @@ -193,9 +192,9 @@

if (key instanceof String && "*".equals(key)) {
xbeanSet = NameSet.EVERYTHING;
} else if (key instanceof List<?>) {
} else if (key instanceof List<?> list) {
NameSetBuilder xbeanSetBuilder = new NameSetBuilder();
for (Object o : (List<?>) key) {
for (Object o : list) {
xbeanSetBuilder.add(o.toString());
}
xbeanSet = xbeanSetBuilder.toNameSet();
Expand Down Expand Up @@ -257,8 +256,7 @@
if (!mapByUriPrefix.isEmpty()) {
String uriprefix = null;
for (Object o : mapByUriPrefix.keySet()) {
if (o instanceof String) {
String nextprefix = (String) o;
if (o instanceof String nextprefix) {
if (uriprefix != null && nextprefix.length() < uriprefix.length()) {
continue;
}
Expand Down Expand Up @@ -301,7 +299,7 @@
/**
* @deprecated replaced with {@link #lookupJavanameForQName(QName, int)}
*/
public String lookupJavanameForQName(QName qname) {

Check warning on line 302 in src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java

View workflow job for this annotation

GitHub Actions / build

[dep-ann] deprecated item is not annotated with @deprecated

Check warning on line 302 in src/main/java/org/apache/xmlbeans/impl/config/BindingConfigImpl.java

View workflow job for this annotation

GitHub Actions / Analyze (java)

[dep-ann] deprecated item is not annotated with @deprecated
String result = _qnameTypeMap.get(qname);
return result != null ? result : _qnameDocTypeMap.get(qname);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ static MethodDeclaration getMethod(ClassOrInterfaceDeclaration cls, String name,

private static String[] paramStrings(NodeList<?> params) {
return params.stream().map(p -> {
if (p instanceof Parameter) {
return ((Parameter)p).getType().resolve().describe();
} else if (p instanceof TypeParameter) {
return ((TypeParameter)p).getNameAsString();
if (p instanceof Parameter param) {
return param.getType().resolve().describe();
} else if (p instanceof TypeParameter typeParam) {
return typeParam.getNameAsString();
} else {
return "unknown";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ public String getDocumentation(){

private static String parseDocumentation(XmlObject parseObject){
try {
if (parseObject instanceof Element) {
Element e = (Element) parseObject;
if (parseObject instanceof Element e) {
if (e.getAnnotation() != null) {
Annotation a = e.getAnnotation();
if (a.getDocumentationArray() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ private static String getExtensionInterfaces(SchemaType sType) {
}

private static SchemaTypeImpl getImpl(SchemaType sType) {
if (sType instanceof SchemaTypeImpl) {
return (SchemaTypeImpl) sType;
if (sType instanceof SchemaTypeImpl impl) {
return impl;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ public String getSourceName() {

SchemaField field = getContainerField();
if (field != null) {
if (field instanceof SchemaGlobalElement) {
return ((SchemaGlobalElement) field).getSourceName();
if (field instanceof SchemaGlobalElement element) {
return element.getSourceName();
}
if (field instanceof SchemaGlobalAttribute) {
return ((SchemaGlobalAttribute) field).getSourceName();
if (field instanceof SchemaGlobalAttribute attribute) {
return attribute.getSourceName();
}
}
return null;
Expand Down Expand Up @@ -1867,8 +1867,8 @@ public XmlAnySimpleType newValue(Object obj, boolean validateOnSet) {

// In the case of tree copy, need to call a specla setter to avoid
// set(XmlObject)
if (obj instanceof XmlObject) {
result.set_newValue((XmlObject) obj);
if (obj instanceof XmlObject object) {
result.set_newValue(object);
} else {
result.setObjectValue(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public XmlObject parse(URL url, SchemaType type, XmlOptions options) throws XmlE
conn = url.openConnection();
conn.addRequestProperty("User-Agent", USER_AGENT);
conn.addRequestProperty("Accept", "application/xml, text/xml, */*");
if (conn instanceof HttpURLConnection) {
HttpURLConnection httpcon = (HttpURLConnection) conn;
if (conn instanceof HttpURLConnection httpcon) {
int code = httpcon.getResponseCode();
redirected = (code == HttpURLConnection.HTTP_MOVED_PERM || code == HttpURLConnection.HTTP_MOVED_TEMP);
if (redirected && count > 5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public SchemaTypeLoader getFromTypeLoaderCache(ClassLoader cl) {
}

public void addToTypeLoaderCache(SchemaTypeLoader stl, ClassLoader cl) {
assert (stl instanceof SchemaTypeLoaderImpl) &&
((SchemaTypeLoaderImpl) stl)._classLoader == cl;
assert (stl instanceof SchemaTypeLoaderImpl stli) &&
stli._classLoader == cl;

List<SoftReference<SchemaTypeLoaderImpl>> a = _cachedTypeSystems.get();
// Make sure this entry is at the top of the stack
Expand Down Expand Up @@ -180,8 +180,7 @@ void add(SchemaTypeLoader[] searchPath) {
return;
}
for (SchemaTypeLoader stl : searchPath) {
if (stl instanceof SchemaTypeLoaderImpl) {
SchemaTypeLoaderImpl sub = (SchemaTypeLoaderImpl) stl;
if (stl instanceof SchemaTypeLoaderImpl sub) {
if (sub._classLoader != null || sub._resourceLoader != null) {
add(sub);
} else {
Expand Down
Loading
Loading