Skip to content

fix: add special handling for Object in Types.newInstance() #2102

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public static boolean isAssignableToOrFrom(Class<?> classToCheck, Class<?> anoth
* an array or an interface or be abstract. If an enclosing class, it must be static.
*/
public static <T> T newInstance(Class<T> clazz) {
// This is a workaround for https://github.com/oracle/graal/issues/11429. Remove this line once
// the GraalVM team has provided a solution or workaround for this.
if (clazz.getName().equals("java.lang.Object")) {
return (T) new Object();
}

// TODO(yanivi): investigate "sneaky" options for allocating the class that GSON uses, like
// setting the constructor to be accessible, or possibly provide a factory method of a special
// name
Expand Down
Loading