Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ public class ViewInitializerImpl extends InstrumentationViewInitializer {
}
```

This feature requires a dependency with ASM (which is not provided out-of-the-box in Vaadin 14-23):
```
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.8</version>
</dependency>
```

## Direct Usage

The helper methods can also be used directly from the `JsonMigration` class:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ final class ClassInstrumentationUtil {

private final Map<ClassLoader, InstrumentedClassLoader> classLoaderCache = new WeakHashMap<>();

private static final boolean IS_ASM_PRESENT;

static {
boolean isPresent;
try {
Class.forName("org.objectweb.asm.ClassWriter", false,
ClassInstrumentationUtil.class.getClassLoader());
isPresent = true;
} catch (ClassNotFoundException e) {
isPresent = false;
}
IS_ASM_PRESENT = isPresent;
}

ClassInstrumentationUtil(int version) {
this.version = version;
}
Expand Down Expand Up @@ -123,6 +137,10 @@ public <T extends Component> Class<? extends T> instrumentClass(Class<T> parent)
return parent;
}

if (!IS_ASM_PRESENT) {
throw new IllegalStateException("Missing optional dependency org.ow2.asm:asm:9.8");
}

// Check for accessible no-arg constructor
try {
Constructor<?> defaultConstructor = parent.getDeclaredConstructor();
Expand Down