changeset 47438:81de38607f5d condy-folding

add the reflective error message to the compiler output
author vromero
date Tue, 17 Oct 2017 17:48:27 -0400
parents cb0d4a1e5256
children 9f592fdeaeca
files src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java test/langtools/tools/javac/specialConstantFolding/ReflectiveErrorTest.out
diffstat 3 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Oct 17 17:40:22 2017 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Oct 17 17:48:27 2017 -0400
@@ -3202,7 +3202,8 @@
 compiler.err.type.mismatch.dynamic.arg=\
     type mismatch between dynamic argument and provided method type at invokedynamic()
 
-# 0: string, 1: string
+# 0: string, 1: string, 2: string
 compiler.err.reflective.error=\
     error in reflective call\n\
-    while trying to invoke method \"{0}\" of class \"{1}\"
+    while trying to invoke method \"{0}\" of class \"{1}\"\n\
+    with error message: \"{2}\"
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java	Tue Oct 17 17:40:22 2017 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Constables.java	Tue Oct 17 17:48:27 2017 -0400
@@ -397,7 +397,7 @@
                 IllegalAccessException |
                 IllegalArgumentException |
                 InvocationTargetException ex) {
-            log.error(Errors.ReflectiveError(methodName, hostClass.getCanonicalName()));
+            log.error(Errors.ReflectiveError(methodName, hostClass.getCanonicalName(), ex.getCause().getLocalizedMessage()));
         }
         return null;
     }
@@ -446,7 +446,7 @@
             } catch (ClassNotFoundException |
                     NoSuchFieldException |
                     IllegalAccessException ex) {
-                log.error(tree, Errors.ReflectiveError(sym.name.toString(), className));
+                log.error(tree, Errors.ReflectiveError(sym.name.toString(), className, ex.getCause().getLocalizedMessage()));
             }
         }
         return null;
@@ -545,7 +545,7 @@
                     IllegalAccessException |
                     IllegalArgumentException |
                     InvocationTargetException ex) {
-                log.error(tree, Errors.ReflectiveError(methodName.toString(), className));
+                log.error(tree, Errors.ReflectiveError(methodName.toString(), className, ex.getCause().getLocalizedMessage()));
                 return null;
             }
         }
--- a/test/langtools/tools/javac/specialConstantFolding/ReflectiveErrorTest.out	Tue Oct 17 17:40:22 2017 -0400
+++ b/test/langtools/tools/javac/specialConstantFolding/ReflectiveErrorTest.out	Tue Oct 17 17:48:27 2017 -0400
@@ -1,2 +1,2 @@
-ReflectiveErrorTest.java:11:56: compiler.err.reflective.error: ofDescriptor, java.lang.invoke.MethodTypeRef
+ReflectiveErrorTest.java:11:56: compiler.err.reflective.error: ofDescriptor, java.lang.invoke.MethodTypeRef, Invalid parameter type: ^
 1 error