@@ -250,8 +250,7 @@ public void findBadLoggerUsages(MethodNode methodNode) {
250
250
int lineNumber = -1 ;
251
251
for (int i = 0 ; i < insns .length ; i ++) {
252
252
AbstractInsnNode insn = insns [i ];
253
- if (insn instanceof LineNumberNode ) {
254
- LineNumberNode lineNumberNode = (LineNumberNode ) insn ;
253
+ if (insn instanceof LineNumberNode lineNumberNode ) {
255
254
lineNumber = lineNumberNode .line ;
256
255
}
257
256
if (insn .getOpcode () == Opcodes .INVOKEINTERFACE ) {
@@ -506,8 +505,7 @@ private int getChainedParams(AbstractInsnNode startNode) {
506
505
AbstractInsnNode current = startNode ;
507
506
while (current .getNext () != null ) {
508
507
current = current .getNext ();
509
- if (current instanceof MethodInsnNode ) {
510
- MethodInsnNode method = (MethodInsnNode ) current ;
508
+ if (current instanceof MethodInsnNode method ) {
511
509
if (method .name .equals ("argAndField" )) {
512
510
c ++;
513
511
}
@@ -656,20 +654,18 @@ private static final class PlaceHolderStringInterpreter extends BasicInterpreter
656
654
public BasicValue newOperation (AbstractInsnNode insnNode ) throws AnalyzerException {
657
655
if (insnNode .getOpcode () == Opcodes .LDC ) {
658
656
Object constant = ((LdcInsnNode ) insnNode ).cst ;
659
- if (constant instanceof String ) {
660
- return new PlaceHolderStringBasicValue (calculateNumberOfPlaceHolders (( String ) constant ));
657
+ if (constant instanceof String s ) {
658
+ return new PlaceHolderStringBasicValue (calculateNumberOfPlaceHolders (s ));
661
659
}
662
660
}
663
661
return super .newOperation (insnNode );
664
662
}
665
663
666
664
@ Override
667
665
public BasicValue merge (BasicValue value1 , BasicValue value2 ) {
668
- if (value1 instanceof PlaceHolderStringBasicValue
669
- && value2 instanceof PlaceHolderStringBasicValue
666
+ if (value1 instanceof PlaceHolderStringBasicValue c1
667
+ && value2 instanceof PlaceHolderStringBasicValue c2
670
668
&& value1 .equals (value2 ) == false ) {
671
- PlaceHolderStringBasicValue c1 = (PlaceHolderStringBasicValue ) value1 ;
672
- PlaceHolderStringBasicValue c2 = (PlaceHolderStringBasicValue ) value2 ;
673
669
return new PlaceHolderStringBasicValue (Math .min (c1 .minValue , c2 .minValue ), Math .max (c1 .maxValue , c2 .maxValue ));
674
670
}
675
671
return super .merge (value1 , value2 );
@@ -702,8 +698,8 @@ public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerExcepti
702
698
return new IntegerConstantBasicValue (Type .INT_TYPE , ((IntInsnNode ) insnNode ).operand );
703
699
case Opcodes .LDC : {
704
700
Object constant = ((LdcInsnNode ) insnNode ).cst ;
705
- if (constant instanceof Integer ) {
706
- return new IntegerConstantBasicValue (Type .INT_TYPE , ( Integer ) constant );
701
+ if (constant instanceof Integer integer ) {
702
+ return new IntegerConstantBasicValue (Type .INT_TYPE , integer );
707
703
} else {
708
704
return super .newOperation (insnNode );
709
705
}
@@ -715,22 +711,17 @@ public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerExcepti
715
711
716
712
@ Override
717
713
public BasicValue merge (BasicValue value1 , BasicValue value2 ) {
718
- if (value1 instanceof IntegerConstantBasicValue && value2 instanceof IntegerConstantBasicValue ) {
719
- IntegerConstantBasicValue c1 = (IntegerConstantBasicValue ) value1 ;
720
- IntegerConstantBasicValue c2 = (IntegerConstantBasicValue ) value2 ;
714
+ if (value1 instanceof IntegerConstantBasicValue c1 && value2 instanceof IntegerConstantBasicValue c2 ) {
721
715
return new IntegerConstantBasicValue (Type .INT_TYPE , Math .min (c1 .minValue , c2 .minValue ), Math .max (c1 .maxValue , c2 .maxValue ));
722
- } else if (value1 instanceof ArraySizeBasicValue && value2 instanceof ArraySizeBasicValue ) {
723
- ArraySizeBasicValue c1 = (ArraySizeBasicValue ) value1 ;
724
- ArraySizeBasicValue c2 = (ArraySizeBasicValue ) value2 ;
716
+ } else if (value1 instanceof ArraySizeBasicValue c1 && value2 instanceof ArraySizeBasicValue c2 ) {
725
717
return new ArraySizeBasicValue (Type .INT_TYPE , Math .min (c1 .minValue , c2 .minValue ), Math .max (c1 .maxValue , c2 .maxValue ));
726
718
}
727
719
return super .merge (value1 , value2 );
728
720
}
729
721
730
722
@ Override
731
723
public BasicValue unaryOperation (AbstractInsnNode insnNode , BasicValue value ) throws AnalyzerException {
732
- if (insnNode .getOpcode () == Opcodes .ANEWARRAY && value instanceof IntegerConstantBasicValue ) {
733
- IntegerConstantBasicValue constantBasicValue = (IntegerConstantBasicValue ) value ;
724
+ if (insnNode .getOpcode () == Opcodes .ANEWARRAY && value instanceof IntegerConstantBasicValue constantBasicValue ) {
734
725
String desc = ((TypeInsnNode ) insnNode ).desc ;
735
726
return new ArraySizeBasicValue (
736
727
Type .getType ("[" + Type .getObjectType (desc )),
0 commit comments