Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6047551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:21:48+00:00 2026-05-23T07:21:48+00:00

I am trying to invoke the API with the given input parameters. Input params

  • 0

I am trying to invoke the API with the given input parameters. Input params are coming as a List. Now my job is get the API’s parameter types one by one and build the required type instance from List. I am able to do for simple java types , List, Set but I am stuck at the array.

Method  method = getMethodFromTheClassBasedOnvalues(  loadedClass,   apiName, numberOfParams);
     Type[] apiMethodParams = method.getGenericParameterTypes();
         List<Type> expectedParamTypes = Arrays.asList(apiMethodArgTypes);
     List<Object> actualValues = // method input.

    List<Object> argsList = new ArrayList<Object>();
    for (int i = 0; i < expectedParamTypes.length; i++) {
        argsList.add(castToRequiredType(expectedParamTypes.get(i),
                actualValues.get(i)));

    method.invoke(loadClass.newInstance(), argsList.toArray());

The problem comes when I get the method which is of type API (String, String[]) I try to get GenericTypes by calling method.getGenericParameterTypes() which returns and array something like this :
[class java.lang.String, class [Ljava.lang.String;] or if one parameter [Ljava.lang.String;
Based on this how would I know if its taking Array of String. I see difference is class name is starting after [L and finishes with; but is it guaranteed?
Will the bevhiour be same for CustomObject[] also?

Is there any smart way to know if the method is taking an array and to build it lately?
Any thoughts in this direction will help.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:21:49+00:00Added an answer on May 23, 2026 at 7:21 am

    Try to use

    Class[] Mehotd.getParameterTypes()

    After that you can call Class.isArray() and determine does this parameter class is array

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a C# P/Invoke wrapper for a C API (a
I am trying to call the PrintDlgW Win32 API from C# via P/Invoke. With
I am trying to invoke an ajax call as soon as my input fields
When trying to invoke a method on an external webservice (over the Internet) it
We have consumed a third party web service and are trying to invoke it
I'm trying to find a way to invoke the Ctrl+Alt+Delete dialog on a Windows
Trying to get my css / C# functions to look like this: body {
I am trying to test a dao method which uses the hibernate criteria API,
I trying to invoke a web service, which has an Basic HTTP Authentication. I
Am trying to invoke a public web-service using a java client but am getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.