Skip to content

Commit

Permalink
fix the deprecated method as of 9
Browse files Browse the repository at this point in the history
  • Loading branch information
ozlerhakan committed Mar 11, 2023
1 parent b66241d commit ca30938
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/poiji/util/ReflectUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static <T> T newInstanceOf(Class<T> type) {
T obj;
try {
Constructor<T> constructor = type.getDeclaredConstructor();
if (!constructor.isAccessible()) {
if (!constructor.canAccess(null)) {

This comment has been minimized.

Copy link
@DManstrator

DManstrator Mar 13, 2023

Is that really safe? From what I saw in the source code of AccessibleObject, null is treated as an illegal value.

I honestly don't know what could be passed here instead but I wanted to point it out.

Edit: This is correct behaviour as explained in #282.

constructor.setAccessible(true);
}
obj = constructor.newInstance();
Expand All @@ -32,12 +32,13 @@ public static <T> T newInstanceOf(Class<T> type) {
}

/**
* Finds a particular annotation on a class and checks subtypes marked with ExcelCellRange recursively.
* Finds a particular annotation on a class and checks subtypes marked with
* ExcelCellRange recursively.
* <p>
* Recursively does not refer to super classes.
*/
static <T, A extends Annotation> Collection<A> findRecursivePoijiAnnotations(Class<T> typeToInspect,
Class<A> annotationType) {
Class<A> annotationType) {
List<A> annotations = new ArrayList<>();

for (Field field : typeToInspect.getDeclaredFields()) {
Expand Down

0 comments on commit ca30938

Please sign in to comment.