Skip to content

Commit

Permalink
Resolved deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
drasil committed Aug 11, 2023
1 parent ccc4108 commit bcb867b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions BNCompiler/src/main/antlr/org/bn/compiler/parser/ASN1.g
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ AsnOidComponent oidcmp; AsnDefinedValue defval; }
obj_id_component returns [AsnOidComponent oidcmp ]
{oidcmp = new AsnOidComponent(); AsnDefinedValue defval;
String s,n =""; }
: ((num:NUMBER {s=num.getText();oidcmp.num = new Integer(s); oidcmp.numberForm=true;})
: ((num:NUMBER {s=num.getText();oidcmp.num = Integer.valueOf(s); oidcmp.numberForm=true;})
| (LOWER (L_PAREN NUMBER R_PAREN)?)=>((lid:LOWER {oidcmp.name = lid.getText();oidcmp.nameForm=true;})
( L_PAREN
(num1:NUMBER {n=num1.getText(); oidcmp.num = new Integer(n);oidcmp.nameAndNumberForm=true;})
(num1:NUMBER {n=num1.getText(); oidcmp.num = Integer.valueOf(n);oidcmp.nameAndNumberForm=true;})
R_PAREN ) ? )
| (defined_value)=>(defval = defined_value {oidcmp.isDefinedValue=true;oidcmp.defval=defval;}))
;
Expand Down Expand Up @@ -731,7 +731,7 @@ clazz returns [String s]
class_NUMBER returns [AsnClassNumber cnum]
{cnum = new AsnClassNumber() ; String s; }
: ((num:NUMBER {s=num.getText(); cnum.num = new Integer(s);})
: ((num:NUMBER {s=num.getText(); cnum.num = Integer.valueOf(s);})
| (lid:LOWER {s=lid.getText(); cnum.name = s ;}) )
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,6 @@ private void setupMemberFlag(Class<?> cls) {

@Override
public Object newInstance() throws Exception {
return newInstanceConstructor == null ? newInstanceClass.newInstance() : newInstanceConstructor.newInstance();
return newInstanceConstructor == null ? newInstanceClass.getDeclaredConstructor().newInstance() : newInstanceConstructor.newInstance();
}
}
6 changes: 3 additions & 3 deletions JavaLibrary/src/main/java/org/bn/coders/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public <T> T decode(InputStream stream, Class<T> objectClass) throws Exception {
ElementInfo elemInfo = new ElementInfo();
elemInfo.setAnnotatedClass(objectClass);

T objectInstance = objectClass.newInstance();
T objectInstance = objectClass.getDeclaredConstructor().newInstance();
if (objectInstance instanceof IASN1PreparedElement) {
elemInfo.setPreparedInstance(objectInstance);
return (T) decodePreparedElement(decodeTag(stream), objectClass, elemInfo, stream).getValue();
Expand Down Expand Up @@ -179,7 +179,7 @@ protected Object createInstanceForElement(Class objectClass, ElementInfo element
}
}
if (result == null) {
result = objectClass.newInstance();
result = objectClass.getDeclaredConstructor().newInstance();
/*Constructor decl = objectClass.getDeclaredConstructor();
decl.setAccessible(true);
result = decl.newInstance();*/
Expand Down Expand Up @@ -338,7 +338,7 @@ public <T> DecodedObject<T> decodeEnum(DecodedObject<Integer> decodedTag, Class<

DecodedObject<Integer> itemValue = decodeEnumItem(decodedTag, field.getType(), enumClass, elementInfo, stream);
if (itemValue != null) {
T result = objectClass.newInstance();
T result = objectClass.getDeclaredConstructor().newInstance();

Field param = null;
for (Field enumItem : enumClass.getDeclaredFields()) {
Expand Down
2 changes: 1 addition & 1 deletion JavaLibrary/src/main/java/org/bn/coders/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected int encodeSequenceField(Object object, int fieldIdx, Field field, Outp
return 0;
} else if ( CoderUtils.isDefaultField(field, info) ) {
// skip the field if the current value equals to the default value (this is optional for BER, but mandatory for DER)
Object newSequenceInstance = elementInfo.hasPreparedInfo() ? elementInfo.getPreparedInfo().newInstance() : object.getClass().newInstance();
Object newSequenceInstance = elementInfo.hasPreparedInfo() ? elementInfo.getPreparedInfo().newInstance() : object.getClass().getDeclaredConstructor().newInstance();
CoderUtils.initDefaultValues(newSequenceInstance);
Object defaultFieldValue = invokeGetterMethodForField(field, newSequenceInstance, info);
return CoderUtils.equals(defaultFieldValue, invokeObjResult) ? 0 : encodeClassType(invokeObjResult, stream, info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public <T> DecodedObject<T> decodeNull(DecodedObject<Integer> decodedTag, Class<
return null;
}
stream.read(); // ignore null length
return new DecodedObject<>(objectClass.newInstance(), 1);
return new DecodedObject<>(objectClass.getDeclaredConstructor().newInstance(), 1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public DecodedObject<byte[]> decodeAny(DecodedObject<Integer> decodedTag, Class
public <T> DecodedObject<T> decodeNull(DecodedObject<Integer> decodedTag, Class<T> objectClass,
ElementInfo elementInfo, InputStream stream) throws Exception {

return new DecodedObject<>(objectClass.newInstance());
return new DecodedObject<>(objectClass.getDeclaredConstructor().newInstance());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ protected int encodeSequencePreamble(Object object, Field[] fields, ElementInfo
if (invokeObjResult==null) {
((BitArrayOutputStream) stream).writeBit(false);
} else if (CoderUtils.isDefaultField(field, info)) {
Object newSequenceInstance = elementInfo.hasPreparedInfo() ? elementInfo.getPreparedInfo().newInstance() : object.getClass().newInstance();
Object newSequenceInstance = elementInfo.hasPreparedInfo() ? elementInfo.getPreparedInfo().newInstance() : object.getClass().getDeclaredConstructor().newInstance();
CoderUtils.initDefaultValues(newSequenceInstance);
Object defaultFieldValue = invokeGetterMethodForField(field, newSequenceInstance, info);
((BitArrayOutputStream) stream).writeBit(!CoderUtils.equals(defaultFieldValue, invokeObjResult));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public TestRecursiveDefinetion createTestRecursiveDefinition() {

public TestI createUnboundedTestInteger() {
TestI value = new TestI();
value.setValue(new Long(0xFAFBFC));
value.setValue(Long.valueOf(0xFAFBFC));
return value;
}

Expand Down

0 comments on commit bcb867b

Please sign in to comment.