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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:43:39+00:00 2026-06-06T08:43:39+00:00

I wondered if Java7’s new invokedynamic bytecode instruction could be used to implement multiple

  • 0

I wondered if Java7’s new invokedynamic bytecode instruction could be used to implement multiple dispatch for the Java language. Would the new API under java.lang.invoke be helpful to perform such a thing?

The scenario I was thinking about looked as follows. (This looks like an application case for the visitor design pattern, but there may be reasons that this is not a viable option.)

class A {} 
class A1 extends A {}
class A2 extends A {}

class SomeHandler {
    private void doHandle(A1 a1) { ... }
    private void doHandle(A2 a2) { ... }
    private void doHandle(A a) { ... }

    public void handle(A a) {
        MultipleDispatch.call(this, "doHandle", a);
    }
}

The library class MultipleDispatch would then do something of the kind:

class MultipleDispatch {

    public static Object call(Object receiver, String method, Object...arg) {
        // something like that in byte code
        #invokeDynamic "doHandle" "someBootstrap"
    }

    static CallSite someBootstrap {
        // resolve that dynamic method call.
    }
}

(I am aware of MultiJava, but can this be achieved in a Java-pure fashion?)

  • 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-06T08:43:41+00:00Added an answer on June 6, 2026 at 8:43 am

    Since I have no experience with invokedynamic, I do not know how good the performance and type-safety would be, but can only give some pointers:

    • the Da Vinci Machine Project offers multiple dispatch via invokedynamic (see Multiple Dispatch/src/invokedynamicmultipledispatch/);
    • Charles Oliver Natter has talked about applications of invokedynamic on JAX2012. The slides do not go into details at all, but I think I came across more details in a video or podcast talking about JAX2012, which I cannot find right now.
    • Christopher Dutchyn’s JVM Multiple Dispatch is an alternative approach without invokedynamic. His COOTS ’01 Paper and these slides have a lot of performance information/benchmarking (and are a good read after you’ve finished your disseration 😉
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wondered if there are any libraries in Java or any other language
Wondered if someone could help me write a MySQL query. I noticed in my
I wondered if there is a programming language which compiles to machine code/binary that
I wondered if anyone could shed some light on the way in which layers
I've used the State pattern to implement a simple finite state machine. Looking at
This is something I've always wondered: Why is PHP slower than Java or C#,
I'm currently writing a Java application to be used with a Windows-Machine authed with
I decided to implement a very simple program recursively, to see how well Java
I recently used the shift operators in Java and noticed that the >> operator
I have always wondered why the garbage collector in Java activates whenever it feels

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.