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 7747707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:35:45+00:00 2026-06-01T10:35:45+00:00

For a better understanding of my question, see the following classes: public interface Invoker<R>

  • 0

For a better understanding of my question, see the following classes:

public interface Invoker<R> {
  public String getName();
  public R getResult();
}

Implementation:

public class RepairFetcher implements Invoker<List<String>> {

  @Override
  public String getName() {
    return this.getClass().getSimpleName();
  }

  @Override
  public List<String> getResult() {
    return new ArrayList<String>();
  }

}

The class where it goes wrong:

public class OperationService {

   public <R> R invoke(Class<R> invoker, Object... parameters) {
     WebserviceOperation<R> operation = new WebserviceOperation<R>(invoker);
     Invoker<R> instance = operation.getInstance();

     return instance.getResult();
   }

}

The main class:

public class Main {

  public static void main(String[] args) {

    OperationService operationService = new OperationService();
    operationService.invoke(RepairFetcher.class, new Object[] {});

  }

}

The problem:
At this moment the method

operationService.invoke(RepairFetcher.class, new Object[] {});

returns an RepairFetcher, which is not so weird because of the argument in the invoke method:

Class invoker

Which returns R, which is a RepairFetcher.class.

What I want
I don’t want the invoke method to return the RepairFetcher class, but I want it to return the declared Type, which is List< String>.

Is this possible, and if so, how to implement this?

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-06-01T10:35:46+00:00Added an answer on June 1, 2026 at 10:35 am

    Not sure, but try:

    public <T, R extends Invoker<T>> T invoke(Class<R> invoker, Object... parameters) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created this page for better understanding the question. As you can see using
See comment in Main(). Why can't I perform the following? public class SomeList<T> :
In asking this question, I'm looking for either better understanding of the situation or
I have two basic interface-related concepts that I need to have a better understanding
This is a better understanding of a question I had earlier. I have the
EDIT: I completely reworked this question to reflect my better understanding of the problem
Question Edited for better understanding: I have a WCF service and any of my
I'd like to get a better understanding of the isAssignableFrom behaviour in Java between
I'm trying to get a better understanding than I've been able to so far...it's
I'm writing a simple calendar control for better understanding of WPF. I have a

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.