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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:14:50+00:00 2026-05-28T04:14:50+00:00

I have the following definition: public interface MessageResponseHandler<T extends MessageBody> { public void responsed(Message<T>

  • 0

I have the following definition:

public interface MessageResponseHandler<T extends MessageBody> {
    public void responsed(Message<T> msg);
}

public class DeviceClientHelper {
    public MessageResponseHandler<? extends MessageBody> messageHandler;

    setHandler(MessageResponseHandler<? extends MessageBody> h){
        this.messageHandler = h;
    }

    public someMethod(Object message){
        Message<? extends MessageBody> msg = (Message<? extends MessageBody>) message;
        if (this.messageHandler != null) {
            this.messageHandler.responsed(msg);
        }
    }
}

I couldn’t figure out why in the someMethod() method, the invocation of

this.messageHandler.responsed(msg);

would give me a wired compiler error in eclipse. something like:

the method responsed(Message<capture#3-of ? extends MessageBody>) in
the type MessageResponseHandler<capture#3-of ? extends MessageBody> is
not applicable for the arguments (Message<capture#4-of ? extends
MessageBody>)

what is the “catpure” means in the error message anyway?

  • 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-28T04:14:51+00:00Added an answer on May 28, 2026 at 4:14 am

    You’re saying DeviceClientHelper has a messageHandler for some subclass of MessageBody. And someMethod has a message also for some subclass of MessageBody. However, there’s nothing requiring them to be the same subclass of MessageBody, so the call to responsed is not valid.

    To make them use the same subclass, make the DeviceClientHelper generic on a specific subclass of MessageBody like so:

    interface MessageResponseHandler<T extends MessageBody> {
        public void responsed(Message<T> msg);
    }
    
    public class DeviceClientHelper<T extends MessageBody> {
        public MessageResponseHandler<T> messageHandler;
    
        void setHandler(MessageResponseHandler<T> h){
            this.messageHandler = h;
        }
    
        public void someMethod(Object message){
            Message<T> msg = (Message<T>) message;
            if (this.messageHandler != null) {
                this.messageHandler.responsed(msg);
            }
        }
    }
    

    However, your MessageResponseHandler interface probably doesn’t need to care about the MessageBody class. This depends on how it’s actually used, but something like this might work better:

    interface MessageResponseHandler {
        public void responsed(Message<? extends MessageBody> msg);
    }
    

    And then you can remove the generic type from the messageHandler field and keep the original someMethod implementation.

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

Sidebar

Related Questions

I have the following class definition: class IRenderable { public: virtual void Render( wxBitmap
I have the following interface definition: public interface IResEnume<out TModel> : IEnumerable<TModel> where TModel
I have the following interface: public interface Iface { void Sample1(); void Sample1(bool value);
I have the following definitions. interface IWeapon {} class Warrior { [Inject] public IEnumerable<IWeapon>
I have got the following interface definition: public interface ICommandHandler { ILogger Logger {
I have the following DTO definition:- [DataContract] public class AddProductDTO { [DataMember] public string
I have the following record definition E3Vector3T = packed record public x: E3FloatT; y:
I have the following class definition: template<typename QueueItemT> class QueueBC { protected: QueueBC() {}
Let's have the following class definition: CThread::CThread () { this->hThread = NULL; this->hThreadId =
I have a the following method definition in my class: virtual Calc* Compile( Evaluator*

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.