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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:29:14+00:00 2026-05-27T10:29:14+00:00

newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h); Returns an instance of a proxy class for

  • 0
newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h); 

Returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler.

I need to encapsulate instance returned by this method (for example,into some other class) so, that it will also extend other class. So the final class will extend one class and implement specified interfaces.

class to extend is:

public class IProxy {

ObjectRef oref;

public IProxy(ObjectRef oref) {
    this.oref = oref;
}

}

so the process should be :

MyInterface() mi=(MyInterface) newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h);

// some magic trick

and in the end I would like to have instance of class that extends IProxy and implements all interfaces that mi did implement.

  • 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-27T10:29:15+00:00Added an answer on May 27, 2026 at 10:29 am

    You cannot do it, because the object returned from newProxyInstance already inherits from some other class, and you cannot inherit from two classes in Java.

    You need to keep oref as an instance variable of your class that implements the InvocationHandler interface. You will initialize oref in the constructor of the InvocationHandler, and provide an interface to access oref through a method:

    public interface IProxy {
        ObjectRef getOref();
    }
    

    Your InvocationHandler should respond to calls of getOref by returning its oref member.

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

Sidebar

Related Questions

Given: Object innerProxy = ... Object proxy = java.lang.reflect.Proxy. newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{type}, innerProxy); How
I'm a little bit confused by this scenario: I have a class that implements
I am trying to implement a factory class that generates objects and intercept all
According to the documentation : [ java.lang.reflect. ] Proxy provides static methods for creating
I was dealing with hibernate, trying to figure out the run-time class behind proxied
In java it's possible to dynamically implement an interface using a dynamic proxy, something
I want to define a method interceptor in a Java program in other words
I'm trying to intercept the method persist and update of javax.persistence.EntityManager in a Seam
Actually, This is not a question but really I need your opinions in a
I'm trying to make modal frame in Java Applet such like shown here: http://www.java2s.com/Tutorial/Java/0240__Swing/Showthegivenframeasmodaltothespecifiedowner.htm

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.