File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
src/main/java/com/flowingcode/vaadin/jsonmigration Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,15 @@ public class ViewInitializerImpl extends InstrumentationViewInitializer {
152152}
153153```
154154
155+ This feature requires a dependency with ASM (which is not provided out-of-the-box in Vaadin 14-23):
156+ ```
157+ <dependency>
158+ <groupId>org.ow2.asm</groupId>
159+ <artifactId>asm</artifactId>
160+ <version>9.8</version>
161+ </dependency>
162+ ```
163+
155164## Direct Usage
156165
157166The helper methods can also be used directly from the ` JsonMigration ` class:
Original file line number Diff line number Diff line change @@ -65,6 +65,20 @@ final class ClassInstrumentationUtil {
6565
6666 private final Map <ClassLoader , InstrumentedClassLoader > classLoaderCache = new WeakHashMap <>();
6767
68+ private static final boolean IS_ASM_PRESENT ;
69+
70+ static {
71+ boolean isPresent ;
72+ try {
73+ Class .forName ("org.objectweb.asm.ClassWriter" , false ,
74+ ClassInstrumentationUtil .class .getClassLoader ());
75+ isPresent = true ;
76+ } catch (ClassNotFoundException e ) {
77+ isPresent = false ;
78+ }
79+ IS_ASM_PRESENT = isPresent ;
80+ }
81+
6882 ClassInstrumentationUtil (int version ) {
6983 this .version = version ;
7084 }
@@ -123,6 +137,10 @@ public <T extends Component> Class<? extends T> instrumentClass(Class<T> parent)
123137 return parent ;
124138 }
125139
140+ if (!IS_ASM_PRESENT ) {
141+ throw new IllegalStateException ("Missing optional dependency org.ow2.asm:asm:9.8" );
142+ }
143+
126144 // Check for accessible no-arg constructor
127145 try {
128146 Constructor <?> defaultConstructor = parent .getDeclaredConstructor ();
You can’t perform that action at this time.
0 commit comments