This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch MDEP-679v2 in repository https://gitbox.apache.org/repos/asf/maven-dependency-analyzer.git
commit 0429bf6c49e39a3d8d97f93e02512f7d538f4cda Author: John Lin <[email protected]> AuthorDate: Sat Mar 21 10:00:34 2020 +0800 [MDEP-679] Refactor: extract helper functions in ConstantPoolParser --- .../analyzer/asm/ConstantPoolParser.java | 71 ++++++++++++++++++---- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java b/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java index 8ff1ccd..1e30726 100644 --- a/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java +++ b/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java @@ -134,37 +134,34 @@ public class ConstantPoolParser case CONSTANT_METHODREF: case CONSTANT_INTERFACEMETHODREF: case CONSTANT_NAME_AND_TYPE: - buf.getChar(); - buf.getChar(); + consumeReference( buf ); break; case CONSTANT_INTEGER: - buf.getInt(); + consumeInt( buf ); break; case CONSTANT_FLOAT: - buf.getFloat(); + consumeFloat( buf ); break; case CONSTANT_DOUBLE: - buf.getDouble(); + consumeDouble( buf ); ix++; break; case CONSTANT_LONG: - buf.getLong(); + consumeLong( buf ); ix++; break; case CONSTANT_METHODHANDLE: - buf.get(); - buf.getChar(); + consumeMethodHandle( buf ); break; case CONSTANT_INVOKE_DYNAMIC: - buf.getChar(); - buf.getChar(); + consumeInvokeDynamic( buf ); break; case CONSTANT_MODULE: - buf.getChar(); + consumeModule( buf ); break; case CONSTANT_PACKAGE: - buf.getChar(); - break; + consumePackage( buf ); + break; } } Set<String> result = new HashSet<>(); @@ -219,4 +216,52 @@ public class ConstantPoolParser // without a slash, class must be in unnamed package, which can't be imported return className.indexOf( '/' ) != -1; } + + private static void consumeReference( ByteBuffer buf ) + { + buf.getChar(); + buf.getChar(); + } + + private static void consumeInt( ByteBuffer buf ) + { + buf.getInt(); + } + + private static void consumeFloat( ByteBuffer buf ) + { + buf.getFloat(); + } + + private static void consumeDouble( ByteBuffer buf ) + { + buf.getDouble(); + } + + private static void consumeLong( ByteBuffer buf ) + { + buf.getLong(); + } + + private static void consumeMethodHandle( ByteBuffer buf ) + { + buf.get(); + buf.getChar(); + } + + private static void consumeInvokeDynamic( ByteBuffer buf ) + { + buf.getChar(); + buf.getChar(); + } + + private static void consumeModule( ByteBuffer buf ) + { + buf.getChar(); + } + + private static void consumePackage( ByteBuffer buf ) + { + buf.getChar(); + } }
