Skip to content

Instantly share code, notes, and snippets.

@HarrisonMc555
Created October 18, 2021 19:55
Show Gist options
  • Save HarrisonMc555/a700b51f99d854e1287091477c602d75 to your computer and use it in GitHub Desktop.
Save HarrisonMc555/a700b51f99d854e1287091477c602d75 to your computer and use it in GitHub Desktop.
Patch to improve error message for failing to instantiate constructor for abstract class
diff --git a/jdk/internal/reflect/ReflectionFactory.java b/jdk/internal/reflect/ReflectionFactory.java
--- a/jdk/internal/reflect/ReflectionFactory.java
+++ b/jdk/internal/reflect/ReflectionFactory.java
@@ -225,7 +225,8 @@
Class<?> declaringClass = c.getDeclaringClass();
if (Modifier.isAbstract(declaringClass.getModifiers())) {
- return new InstantiationExceptionConstructorAccessorImpl(null);
+ return new InstantiationExceptionConstructorAccessorImpl
+ ("Can not instantiate abstract class");
}
if (declaringClass == Class.class) {
return new InstantiationExceptionConstructorAccessorImpl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment