55import java .io .File ;
66import java .io .FileInputStream ;
77import java .io .IOException ;
8- import java .util .Objects ;
98import org .jd .core .v1 .model .classfile .constant .Constant ;
109import org .jd .core .v1 .model .classfile .constant .ConstantClass ;
1110import org .jd .core .v1 .model .classfile .constant .ConstantUtf8 ;
@@ -29,8 +28,9 @@ public static String ExtractDirectoryPath(String pathToClass) {
2928 BufferedInputStream bis = new BufferedInputStream (fis );
3029 DataInputStream dis = new DataInputStream (bis )) {
3130 int magic = dis .readInt ();
32- if (magic != ClassFileReader .JAVA_MAGIC_NUMBER )
31+ if (magic != ClassFileReader .JAVA_MAGIC_NUMBER ) {
3332 throw new ClassFileFormatException ("Invalid Java .class file" );
33+ }
3434
3535 /* int minor_version = */
3636 dis .readUnsignedShort ();
@@ -43,16 +43,18 @@ public static String ExtractDirectoryPath(String pathToClass) {
4343 dis .readUnsignedShort ();
4444 int this_class = dis .readUnsignedShort ();
4545
46- if (this_class > Objects . requireNonNull ( constants ) .length ) {
46+ if (this_class > constants .length ) {
4747 throw new ClassFileFormatException ("Unknown Java structure" );
4848 }
4949 Constant c = constants [this_class ];
50- if ((c == null ) || (c .getTag () != Constant .CONSTANT_Class ))
50+ if ((c == null ) || (c .getTag () != Constant .CONSTANT_Class )) {
5151 throw new ClassFileFormatException ("Invalid constant pool" );
52+ }
5253
5354 c = constants [((ConstantClass ) c ).getNameIndex ()];
54- if ((c == null ) || (c .getTag () != Constant .CONSTANT_Utf8 ))
55+ if ((c == null ) || (c .getTag () != Constant .CONSTANT_Utf8 )) {
5556 throw new ClassFileFormatException ("Invalid constant pool" );
57+ }
5658
5759 String internalClassName = ((ConstantUtf8 ) c ).getValue ();
5860 String pathSuffix = internalClassName .replace (
@@ -61,8 +63,9 @@ public static String ExtractDirectoryPath(String pathToClass) {
6163
6264 int index = pathToClass .indexOf (pathSuffix );
6365
64- if (index < 0 )
66+ if (index < 0 ) {
6567 throw new ClassFileFormatException ("Invalid internal class name" );
68+ }
6669
6770 directoryPath = pathToClass .substring (0 , index );
6871 } catch (IOException e ) {
@@ -87,9 +90,6 @@ public static String ExtractInternalPath(
8790 private static Constant [] DeserializeConstants (DataInputStream dis )
8891 throws IOException {
8992 int count = dis .readUnsignedShort ();
90- if (count == 0 )
91- return null ;
92-
9393 Constant [] constants = new Constant [count ];
9494
9595 for (int i = 1 ; i < count ; i ++) {
@@ -112,12 +112,15 @@ private static Constant[] DeserializeConstants(DataInputStream dis)
112112 case Constant .CONSTANT_FieldRef :
113113 case Constant .CONSTANT_MethodRef :
114114 case Constant .CONSTANT_InterfaceMethodRef :
115+ case Constant .CONSTANT_InvokeDynamic :
115116 case Constant .CONSTANT_NameAndType :
116117 case Constant .CONSTANT_Integer :
117118 case Constant .CONSTANT_Float :
118119 dis .read ();
120+ case Constant .CONSTANT_MethodHandle :
119121 dis .read ();
120122 case Constant .CONSTANT_String :
123+ case Constant .CONSTANT_MethodType :
121124 dis .read ();
122125 dis .read ();
123126 break ;
0 commit comments