1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Bump to Gradle 8.10.2, require Java 11

Bump Gradle from 6.8.3 to 8.10.2 and increase the minimum required
Java version from 8 to 11 (SMACK-953).

The switch from Java 8 to 11 caused some Bytecode portability issues
regarding NIO Buffers. Java changed with version 9 the return type of
some subclasses of Buffer to return the specific Buffer type instead
of the Buffer superclass [JDK-4774077]. For example, ByteBuffer.filp()
previously returned Buffer, while it does return ByteBuffer now.

This sensible change was not reflected by the Android API [1], which
means that AnimalSniffer rightfully started to complain that there is
no method "ByteBuffer ByteBuffer.flip()" in Android, there is only
"Buffer ByteBuffer.flip()", and those are incompatible methods on
Java's Bytecode layer.

As workaround, this changes

    return charBuffer.flip().toString();

to

    ((java.nio.Buffer) charBuffer).flip();
    return charBuffer.toString();

to restore the Bytecode portability between Android and Java.

Errorprone also got new checks, of which JavaUtilDate and JdkObsolete
are wroth mentioning.

JavaUtilData basically strongly recommends to use Java's newer time
API over java.util.Date. But since Smack was Java 8 until now,
j.u.Date is widely used.

Similar JdkObsolete mentions obsolete JDK APIs, like data structures
like Vector and Stack. But mostly LinkedList, which should usually be
replaced by ArrayList. And this is what this commit largely does.

JDK-4774077: https://bugs.openjdk.org/browse/JDK-4774077
1: https://issuetracker.google.com/issues/369219141
This commit is contained in:
Florian Schmaus 2024-09-25 11:43:47 +02:00
parent d8d066b831
commit 1e5d34eacf
136 changed files with 1161 additions and 1220 deletions

View file

@ -1,3 +1,8 @@
plugins {
id 'org.igniterealtime.smack.java-common-conventions'
id 'org.igniterealtime.smack.android-conventions'
}
description = """\
Smack legacy extensions.
Usually XEPs in the state 'retracted', 'rejected', 'deprecated',

View file

@ -203,7 +203,7 @@ public class AgentRoster {
/**
* Returns the presence info for a particular agent, or <code>null</code> if the agent
* is unavailable (offline) or if no presence information is available.<p>
* is unavailable (offline) or if no presence information is available.
*
* @param user a fully qualified xmpp JID. The address could be in any valid format (e.g.
* "domain/resource", "user@domain" or "user@domain/resource").

View file

@ -710,6 +710,7 @@ public class AgentSession {
}
}
@SuppressWarnings("JavaUtilDate")
private void fireOfferRequestEvent(OfferRequestProvider.OfferRequestPacket requestPacket) {
Offer offer = new Offer(this.connection, this, requestPacket.getUserID(),
requestPacket.getUserJID(), this.getWorkgroupJID(),
@ -723,6 +724,7 @@ public class AgentSession {
}
}
@SuppressWarnings("JavaUtilDate")
private void fireOfferRevokeEvent(OfferRevokeProvider.OfferRevokePacket orp) {
RevokedOffer revokedOffer = new RevokedOffer(orp.getUserJID(), orp.getUserID(),
this.getWorkgroupJID(), orp.getSessionID(), orp.getReason(), new Date());

View file

@ -54,6 +54,7 @@ public class AgentChatHistory extends IQ {
private final List<AgentChatSession> agentChatSessions = new ArrayList<>();
@SuppressWarnings("JavaUtilDate")
public AgentChatHistory(EntityBareJid agentJID, int maxSessions, Date startDate) {
this();
this.agentJID = agentJID;
@ -116,6 +117,7 @@ public class AgentChatHistory extends IQ {
return agentChatHistory;
}
@SuppressWarnings("JavaUtilDate")
private static AgentChatSession parseChatSetting(XmlPullParser parser)
throws XmlPullParserException, IOException {
boolean done = false;

View file

@ -145,6 +145,7 @@ public final class QueueDetails implements ExtensionElement {
*/
public static class Provider extends ExtensionElementProvider<QueueDetails> {
@SuppressWarnings("JavaUtilDate")
@Override
public QueueDetails parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.workgroup.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -45,6 +45,7 @@ public class MetaDataUtils {
* @throws XmlPullParserException if an error occurs while parsing the XML.
* @throws IOException if an error occurs while parsing the XML.
*/
@SuppressWarnings("MixedMutabilityReturnType")
public static Map<String, List<String>> parseMetaData(XmlPullParser parser) throws XmlPullParserException, IOException {
XmlPullParser.Event eventType = parser.getEventType();
@ -52,7 +53,7 @@ public class MetaDataUtils {
if ((eventType == XmlPullParser.Event.START_ELEMENT)
&& parser.getName().equals(MetaData.ELEMENT_NAME)
&& parser.getNamespace().equals(MetaData.NAMESPACE)) {
Map<String, List<String>> metaData = new Hashtable<>();
Map<String, List<String>> metaData = new LinkedHashMap<>();
eventType = parser.next();