3333import net .bytebuddy .utility .dispatcher .JavaDispatcher ;
3434import net .bytebuddy .utility .nullability .AlwaysNull ;
3535import net .bytebuddy .utility .nullability .MaybeNull ;
36+ import org .objectweb .asm .Opcodes ;
3637
3738import java .lang .annotation .Annotation ;
3839import java .lang .reflect .AccessibleObject ;
@@ -230,6 +231,13 @@ public String toString() {
230231 */
231232 abstract class ForLoadedParameter <T extends AccessibleObject > extends InDefinedShape .AbstractBase {
232233
234+ /**
235+ * The name of the {@code java.lang.reflect.MalformedParametersException}. Due to compiler bugs, parameter
236+ * declarations might not always be legal, and by checking for this exception, one can trigger a fallback
237+ * behaviour.
238+ */
239+ private static final String MALFORMED_PARAMETERS_EXCEPTION = "java.lang.reflect.MalformedParametersException" ;
240+
233241 /**
234242 * A dispatcher for reading properties from {@code java.lang.reflect.Parameter} instances.
235243 */
@@ -279,7 +287,14 @@ private static <T> T doPrivileged(PrivilegedAction<T> action) {
279287 * {@inheritDoc}
280288 */
281289 public String getName () {
282- return PARAMETER .getName (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
290+ try {
291+ return PARAMETER .getName (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
292+ } catch (RuntimeException exception ) {
293+ if (exception .getClass ().getName ().equals (MALFORMED_PARAMETERS_EXCEPTION )) {
294+ return super .getName ();
295+ }
296+ throw exception ;
297+ }
283298 }
284299
285300 /**
@@ -293,14 +308,28 @@ public int getIndex() {
293308 * {@inheritDoc}
294309 */
295310 public boolean isNamed () {
296- return PARAMETER .isNamePresent (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
311+ try {
312+ return PARAMETER .isNamePresent (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
313+ } catch (RuntimeException exception ) {
314+ if (exception .getClass ().getName ().equals (MALFORMED_PARAMETERS_EXCEPTION )) {
315+ return false ;
316+ }
317+ throw exception ;
318+ }
297319 }
298320
299321 /**
300322 * {@inheritDoc}
301323 */
302324 public int getModifiers () {
303- return PARAMETER .getModifiers (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
325+ try {
326+ return PARAMETER .getModifiers (ParameterList .ForLoadedExecutable .EXECUTABLE .getParameters (executable )[index ]);
327+ } catch (RuntimeException exception ) {
328+ if (exception .getClass ().getName ().equals (MALFORMED_PARAMETERS_EXCEPTION )) {
329+ return super .getModifiers ();
330+ }
331+ throw exception ;
332+ }
304333 }
305334
306335 /**
0 commit comments