changeset 55803:6e432194ee97

8042748: Clarify exception thrown by ParameterizedTypeImpl.validateConstructorArguments() Reviewed-by: lancea
author darcy
date Sun, 09 Jun 2019 15:48:57 -0700
parents 84b9996abbee
children ea43db53de91
files src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java	Sun Jun 09 15:21:43 2019 -0700
+++ b/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java	Sun Jun 09 15:48:57 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,15 @@
     private void validateConstructorArguments() {
         TypeVariable<?>[] formals = rawType.getTypeParameters();
         // check correct arity of actual type args
-        if (formals.length != actualTypeArguments.length){
-            throw new MalformedParameterizedTypeException();
+        if (formals.length != actualTypeArguments.length) {
+            throw new MalformedParameterizedTypeException(String.format("Mismatch of count of " +
+                                                                        "formal and actual type " +
+                                                                        "arguments in constructor " +
+                                                                        "of %s: %d formal argument(s) "+
+                                                                        "%d actual argument(s)",
+                                                                        rawType.getName(),
+                                                                        formals.length,
+                                                                        actualTypeArguments.length));
         }
         for (int i = 0; i < actualTypeArguments.length; i++) {
             // check actuals against formals' bounds