2 Replies - 162 Views - Last Post: 26 January 2019 - 02:51 AM Rate Topic: -----

#1 [email protected]@@   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-January 19

Illegal argument exception in getDeclaredConstructor

Posted 25 January 2019 - 05:35 PM

I tried accessing the constructor for a class using reflection.

getDeclaredConstructor (String.class,List.class,List.class,List.class,List.class)
And my actual constructor is a constructor with 1 String parameter and 4 two dimensional list. But this throws Illegal argument exception:wrong number of parameters. But if I pass just 1 or 2 parameters it throws no such method exception not illegal argument. Why this happens?
Is This A Good Question/Topic? 0
  • +

Replies To: Illegal argument exception in getDeclaredConstructor

#2 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 762
  • View blog
  • Posts: 5,729
  • Joined: 25-December 13

Re: Illegal argument exception in getDeclaredConstructor

Posted 25 January 2019 - 07:18 PM

Can you post a small, simple program that compiles, executes and shows the problem?
Was This Post Helpful? 1
  • +
  • -

#3 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2728
  • View blog
  • Posts: 4,369
  • Joined: 21-June 11

Re: Illegal argument exception in getDeclaredConstructor

Posted 26 January 2019 - 02:51 AM

getDeclaredConstructor doesn't throw IllegalArgumentExceptions, so you must be getting the exception somewhere else in your code.

I second NormR request for a runnable code sample that reproduces the problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1