From c3881a811b1ba500b6deb1827e26f089e53e6c2a Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 25 Aug 2018 13:26:28 +0000 Subject: [PATCH] fix deprecations --- core/java/src/gnu/getopt/Getopt.java | 28 +++++++++---------- core/java/src/gnu/getopt/LongOpt.java | 2 +- .../java/src/gnu/gettext/GettextResource.java | 2 +- .../net/i2p/crypto/provider/I2PProvider.java | 2 ++ .../southernstorm/noise/protocol/Noise.java | 7 ++--- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/java/src/gnu/getopt/Getopt.java b/core/java/src/gnu/getopt/Getopt.java index caf7f49cac..8a9a44720e 100644 --- a/core/java/src/gnu/getopt/Getopt.java +++ b/core/java/src/gnu/getopt/Getopt.java @@ -935,8 +935,8 @@ checkLongOption() // +option or -option else { - Object[] msgArgs = { progname, new - Character(argv[optind-1].charAt(0)).toString(), + Object[] msgArgs = { progname, + Character.toString(argv[optind-1].charAt(0)), pfound.name }; System.err.println(MessageFormat.format( _messages.getString("getopt.arguments2"), @@ -1138,8 +1138,8 @@ getopt() } else { - Object[] msgArgs = { progname, new - Character(argv[optind].charAt(0)).toString(), + Object[] msgArgs = { progname, + Character.toString(argv[optind].charAt(0)), nextchar }; System.err.println(MessageFormat.format( _messages.getString("getopt.unrecognized2"), @@ -1176,15 +1176,15 @@ getopt() if (posixly_correct) { // 1003.2 specifies the format of this message - Object[] msgArgs = { progname, new - Character((char)c).toString() }; + Object[] msgArgs = { progname, + Character.toString((char)c) }; System.err.println(MessageFormat.format( _messages.getString("getopt.illegal"), msgArgs)); } else { - Object[] msgArgs = { progname, new - Character((char)c).toString() }; + Object[] msgArgs = { progname, + Character.toString((char)c) }; System.err.println(MessageFormat.format( _messages.getString("getopt.invalid"), msgArgs)); } @@ -1208,8 +1208,8 @@ getopt() if (opterr) { // 1003.2 specifies the format of this message. - Object[] msgArgs = { progname, new - Character((char)c).toString() }; + Object[] msgArgs = { progname, + Character.toString((char)c) }; System.err.println(MessageFormat.format( _messages.getString("getopt.requires2"), msgArgs)); } @@ -1270,8 +1270,8 @@ getopt() if (opterr) { // 1003.2 specifies the format of this message - Object[] msgArgs = { progname, new - Character((char)c).toString() }; + Object[] msgArgs = { progname, + Character.toString((char)c) }; System.err.println(MessageFormat.format( _messages.getString("getopt.requires2"), msgArgs)); } @@ -1300,8 +1300,8 @@ getopt() if (opterr) { // 1003.2 specifies the format of this message - Object[] msgArgs = { progname, new - Character((char)c).toString() }; + Object[] msgArgs = { progname, + Character.toString((char)c) }; System.err.println(MessageFormat.format( _messages.getString("getopt.requires2"), msgArgs)); } diff --git a/core/java/src/gnu/getopt/LongOpt.java b/core/java/src/gnu/getopt/LongOpt.java index 9de9f43ad5..644a4b91f5 100644 --- a/core/java/src/gnu/getopt/LongOpt.java +++ b/core/java/src/gnu/getopt/LongOpt.java @@ -127,7 +127,7 @@ LongOpt(String name, int has_arg, if ((has_arg != NO_ARGUMENT) && (has_arg != REQUIRED_ARGUMENT) && (has_arg != OPTIONAL_ARGUMENT)) { - Object[] msgArgs = { new Integer(has_arg).toString() }; + Object[] msgArgs = { Integer.toString(has_arg) }; throw new IllegalArgumentException(MessageFormat.format( _messages.getString("getopt.invalidValue"), msgArgs)); } diff --git a/core/java/src/gnu/gettext/GettextResource.java b/core/java/src/gnu/gettext/GettextResource.java index d0dbc05128..3733a26eea 100644 --- a/core/java/src/gnu/gettext/GettextResource.java +++ b/core/java/src/gnu/gettext/GettextResource.java @@ -148,7 +148,7 @@ public abstract class GettextResource extends ResourceBundle { String[] pluralforms = (String[])localValue; long i = 0; try { - i = ((Long) pluralEvalMethod.invoke(catalog, new Object[] { new Long(n) })).longValue(); + i = ((Long) pluralEvalMethod.invoke(catalog, new Object[] { Long.valueOf(n) })).longValue(); if (!(i >= 0 && i < pluralforms.length)) i = 0; } catch (IllegalAccessException e) { diff --git a/core/java/src/net/i2p/crypto/provider/I2PProvider.java b/core/java/src/net/i2p/crypto/provider/I2PProvider.java index b6b26d396d..3c0e28a15d 100644 --- a/core/java/src/net/i2p/crypto/provider/I2PProvider.java +++ b/core/java/src/net/i2p/crypto/provider/I2PProvider.java @@ -20,6 +20,8 @@ public final class I2PProvider extends Provider { * <code>Security.addProvider()</code> mechanism. */ public I2PProvider() { + // following constructor deprecated in Java 9, + // replaced by (String,String,String) added in Java 9 super(PROVIDER_NAME, 0.1, INFO); AccessController.doPrivileged(new PrivilegedAction<Void>() { diff --git a/router/java/src/com/southernstorm/noise/protocol/Noise.java b/router/java/src/com/southernstorm/noise/protocol/Noise.java index 29764faa25..f21184862a 100644 --- a/router/java/src/com/southernstorm/noise/protocol/Noise.java +++ b/router/java/src/com/southernstorm/noise/protocol/Noise.java @@ -125,11 +125,10 @@ public final class Noise { static void throwBadTagException() throws BadPaddingException { try { + // java since 1.7; android since API 19 Class<?> c = Class.forName("javax.crypto.AEADBadTagException"); - throw (BadPaddingException)(c.newInstance()); - } catch (ClassNotFoundException e) { - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { + throw (BadPaddingException)(c.getDeclaredConstructor().newInstance()); + } catch (Exception e) { } throw new BadPaddingException(); } -- GitLab