Skip to content

Commit

Permalink
Add ClassUtil.isClassInitializer(String) and `ClassUtil.isInstanceI…
Browse files Browse the repository at this point in the history
…nitializer(String)`
  • Loading branch information
tvoc-gs authored and bengt-GS committed Nov 22, 2024
1 parent 014fcdc commit bf594da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions base/src/main/java/proguard/classfile/util/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,31 @@ public static String internalSimpleClassName(String internalClassName) {
/**
* Returns whether the given method name refers to a class initializer or an instance initializer.
*
* @param internalMethodName the internal method name, e.g. "<code>&ltclinit&gt;</code>".
* @return whether the method name refers to an initializer, e.g. <code>true</code>.
* @param internalMethodName The internal method name, e.g. "<code>&ltclinit&gt;</code>".
* @return Whether the method name refers to an initializer, e.g. <code>true</code>.
*/
public static boolean isInitializer(String internalMethodName) {
return internalMethodName.equals(ClassConstants.METHOD_NAME_CLINIT)
|| internalMethodName.equals(ClassConstants.METHOD_NAME_INIT);
return isClassInitializer(internalMethodName) || isInstanceInitializer(internalMethodName);
}

/**
* Returns whether the given method name refers to a class initializer.
*
* @param internalMethodName The internal method name, e.g. "<code>&ltclinit&gt;</code>".
* @return Whether the method name refers to a class initializer, e.g. <code>true</code>.
*/
public static boolean isClassInitializer(String internalMethodName) {
return ClassConstants.METHOD_NAME_CLINIT.equals(internalMethodName);
}

/**
* Returns whether the given method name refers to an instance initializer.
*
* @param internalMethodName The internal method name, e.g. "<code>&ltinit&gt;</code>".
* @return Whether the method name refers to an instance initializer, e.g. <code>true</code>.
*/
public static boolean isInstanceInitializer(String internalMethodName) {
return ClassConstants.METHOD_NAME_INIT.equals(internalMethodName);
}

/**
Expand Down
1 change: 1 addition & 0 deletions docs/md/releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### API improvements

- Rename `CallVisitor` to `CallHandler` and add extra parameters to handle calls accounting for more data.
- Add `ClassUtil.isClassInitializer(String)` and `ClassUtil.isInstanceInitializer(String)`.

## Version 9.1.6

Expand Down

0 comments on commit bf594da

Please sign in to comment.