From c569ad302a156b4124d3be26fcdc0f3ff62e3d67 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Sun, 9 Jun 2019 15:48:57 -0700 Subject: [PATCH] 8042748: Clarify exception thrown by ParameterizedTypeImpl.validateConstructorArguments() Reviewed-by: lancea --- .../reflectiveObjects/ParameterizedTypeImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java b/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java index ed650d41033..248ce9f69a7 100644 --- a/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java +++ b/src/java.base/share/classes/sun/reflect/generics/reflectiveObjects/ParameterizedTypeImpl.java @@ -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 @@ public class ParameterizedTypeImpl implements ParameterizedType { 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