lburgazzoli commented on issue #610: Fix the defineClass exception in 
camel-quarkus-jsonpath while running in native mode
URL: https://github.com/apache/camel-quarkus/issues/610#issuecomment-573203761
 
 
   looking a little bit into this issue you probably need to substitute:
   - `net.minidev.json.JSONValue`
   - `net.minidev.json.JSONWriter`
   
   Something like:
   
   ```java
   @TargetClass(JSONValue.class)
   class JSONValueSubstitution {
       
       @Substitute
        public static void writeJSONString(Object value, Appendable out, 
JSONStyle compression) throws IOException {
                if (value == null) {
                        out.append("null");
                        return;
                }
                Class<?> clz = value.getClass();
                @SuppressWarnings("rawtypes")
                JsonWriterI w = defaultWriter.getWrite(clz);
                if (w == null) {
                        if (clz.isArray())
                                w = JsonWriter.arrayWriter;
                        else {
                                w = 
defaultWriter.getWriterByInterface(value.getClass());
                                if (w == null)
                                        throw new 
UnsupportedOperationException("...")
                        }
                        defaultWriter.registerWriter(w, clz);
                }
                w.writeJSONString(value, out, compression);
        }
   }
   ```
   
   ```java
   @TargetClass(JSONWriter.class)
   class JSONWriterSubstitution {
       @Delete
       static public JsonWriterI<Object> beansWriterASM;
   }
   ```
   
   Not sure it it is enough but the issue is that the library tries to generate 
classes in case it does not find a suitable writer. 
   
   An potential future evolution would be to generate such classes at build 
time.
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to