Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the defineClass exception in camel-quarkus-jsonpath while running in native mode #610

Closed
aldettinger opened this issue Jan 9, 2020 · 5 comments
Assignees

Comments

@aldettinger
Copy link
Contributor

How to reproduce:
Set false in integration-tests/jsonpath/pom.xml
Run mvn clean verify -P native
An issue where the @deleted defineClass method would be accessed is reported.

@aldettinger
Copy link
Contributor Author

Thanks @lburgazzoli for discussing the case.
I will try adding the jsonb extension, or then find what to substitute in order to cut the possibly false unreachable code path detection.

@lburgazzoli
Copy link
Contributor

looking a little bit into this issue you probably need to substitute:

  • net.minidev.json.JSONValue
  • net.minidev.json.JSONWriter

Something like:

@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);
	}
}
@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.

@aldettinger aldettinger self-assigned this Jan 15, 2020
aldettinger added a commit to aldettinger/camel-quarkus that referenced this issue Jan 15, 2020
@aldettinger
Copy link
Contributor Author

@lburgazzoli, you were few brackets from having it fully done :) Thanks for analysis and proposal by the way 👍

aldettinger added a commit to aldettinger/camel-quarkus that referenced this issue Jan 15, 2020
aldettinger added a commit to aldettinger/camel-quarkus that referenced this issue Jan 16, 2020
@aldettinger
Copy link
Contributor Author

I've pushed a fix, let's ensure next build is fine with that.

@aldettinger
Copy link
Contributor Author

The build is fine regarding this ticket, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants