From f27a600db14d745cb7f13f8dc839863078b7f1c7 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:37:32 +0200 Subject: - bug fix on travel date in train link in version 1.3 - bug fix on travel date in train link in version 1.3 - replaced out-dated java functions - switched all tests to non-deprecated functions --- src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java | 2 +- .../asn1/datatypesimpl/SequenceOfUnrestrictedLong.java | 2 +- src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java | 3 ++- src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java | 2 +- src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java | 2 +- src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java | 11 +++++++---- 6 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/org/uic/barcode/asn1') diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java index e12f8ec..e5cfb4c 100644 --- a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java +++ b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java @@ -19,7 +19,7 @@ public class Asn1Integer { } public Long longObject () { - return new Long(value()); + return Long.valueOf(value()); } public Asn1Integer(Long num) { diff --git a/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java b/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java index 6af7352..fdd72e8 100644 --- a/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java +++ b/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java @@ -17,7 +17,7 @@ public class SequenceOfUnrestrictedLong extends Asn1SequenceOf { public SequenceOfUnrestrictedLong(List numbers) { super(); for (Long number: numbers){ - this.add(new Long(number)); + this.add(Long.valueOf(number)); } } diff --git a/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java b/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java index 6f435c4..0b6c9bd 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java @@ -36,7 +36,8 @@ class BitStringCoder implements Decoder, Encoder { throw new AssertionError("Field should be a list of booleans!"); } - List list = (List)obj; + @SuppressWarnings("unchecked") + List list = (List)obj; if (list.size() != size.value()) { throw new AssertionError( "Declared size (" + size.value() + diff --git a/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java b/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java index 892f851..9f88e37 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java @@ -23,7 +23,7 @@ class BooleanCoder implements Decoder, Encoder { @Override public T decode(BitBuffer bitbuffer, Class classOfT, Field field, Annotation[] extraAnnotations, AsnExtractor extractor) { - Boolean result = new Boolean(bitbuffer.get()); + Boolean result = Boolean.valueOf(bitbuffer.get()); UperEncoder.logger.debug(String.format("BOOL: decoded as %s",result)); return (T) result; } diff --git a/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java b/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java index 5ecb925..4d722de 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java @@ -23,7 +23,7 @@ class ByteCoder implements Decoder, Encoder { Class classOfT, Field field, Annotation[] extraAnnotations, AsnExtractor extractor) { UperEncoder.logger.debug("BYTE"); - return (T) new Byte((byte) UperEncoder.decodeConstrainedInt(bitbuffer, UperEncoder.newRange(0, 255, false))); + return (T) Byte.valueOf((byte) UperEncoder.decodeConstrainedInt(bitbuffer, UperEncoder.newRange(0, 255, false))); } @Override diff --git a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java index c256b4f..647a550 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java @@ -334,7 +334,7 @@ public final class UperEncoder { parameterTypes[i] = parameters[i].getClass(); } Constructor constructor = findConsturctor(classOfT, parameters); - boolean constructorIsAccessible = constructor.isAccessible(); + //boolean constructorIsAccessible = constructor.isAccessible(); constructor.setAccessible(true); T result; try { @@ -342,7 +342,7 @@ public final class UperEncoder { } catch (IllegalArgumentException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException("Can't instantiate " + classOfT.getName(), e); } - constructor.setAccessible(constructorIsAccessible); + //constructor.setAccessible(constructorIsAccessible); return result; } @@ -441,7 +441,7 @@ public final class UperEncoder { List optionalOrdinaryFields = new ArrayList<>(); List allFields = new ArrayList<>(); // Excluding test instrumentation. - Map originalAccess = new HashMap<>(); + //Map originalAccess = new HashMap<>(); Asn1ContainerFieldSorter(Class type) { @@ -472,7 +472,7 @@ public final class UperEncoder { if (isTestInstrumentation(f) || isNonAsn1Field(f) ) { continue; } - originalAccess.put(f, f.isAccessible()); + //originalAccess.put(f, f.isAccessible()); f.setAccessible(true); if (isExtension(f)) { extensionFields.add(f); @@ -496,10 +496,13 @@ public final class UperEncoder { } } + public void revertAccess() { + /* for (Entry entry : originalAccess.entrySet()) { entry.getKey().setAccessible(entry.getValue()); } + */ } } -- cgit v1.2.3