Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33504
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jeff Higgins <jeff@invalid.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: methodhandles lookup |
| Date | Fri, 22 Jan 2016 08:57:32 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 70 |
| Message-ID | <n7sqtr$29m$1@dont-email.me> (permalink) |
| References | <1abadfac-e34b-4ff0-8ba5-613355fa928b@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Fri, 22 Jan 2016 08:57:32 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="5e45ef46140b05dc5105f4b40d13e4a5"; logging-data="2358"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZuU8PTsgMP7tpEnIwrd8N6ebnpPlZMTg=" |
| User-Agent | Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) |
| Cancel-Lock | sha1:q2xOsK8Or2sQZdRJBmsL0nfA4bg= |
| Xref | csiph.com comp.lang.java.programmer:33504 |
Show key headers only | View raw
On Fri, 22 Jan 2016 00:19:07 -0800, Philipp Kraus wrote:
> Hello,
>
> I'm trying to create a flexible (dynamic) binding for method calls and I
> have got a problem with overloaded method binding.
> In detail: I have created an own programming language which should call
> a java method. In my own language I have got grammar constructs like
> "foo/bar( "myobject" );". Internal I have got a Map<String, Object>
> which maps the string parameter to an object which will be invoked.
> foo/bar points to the method, in this case foo is the classname and bar
> the method name. So in this example I need a binding to the method
> "public void bar();".
> My language should also use calls like "foo/bar( "myobject", 1 );". In
> this case the Java method "void bar( int x );" should be called.
Not to answer your question.
Xtext - Language Engineering Made Easy! - Eclipse
<https://eclipse.org/Xtext/#intro-quotes>
>
> The basic invoking call works well, but I overloaded method creates a
> problem. If I have got the class
>
> class foo {
> public void bar()
> {
> System.out.println("test");
> }
> }
>
> I do the following:
>
> final Multimap<String, MethodHandle> y = HashMultimap.create();
> for ( final Method x : foo.class.getDeclaredMethods() )
> y.put( x.getSimpleName(), MethodHandles.lookup().unreflect(x) );
>
> This multimap is put to the parser / lexer of my language to resolve
> method names but on calling / invoking I get the problem, that I need
> the correct methodhandle within the multimap depend on the signature.
>
> The problem is a class like class foo {
> public void bar()
> {
> System.out.println("test");
> }
>
> public void bar( int x )
> {
> System.out.println("test " + x);
> }
> }
>
> So my question is, how can I create a dynamic binding on method handles
> depend on the signature?
> And can I cache the method handles / is it a good choice of caching all
> handles? In my case I know during runtime the concrete signature of the
> method, "foo/bar" is executed and on this time I know all arguments of
> the method, so I can create at this point the binding. How can I do this
> in a fast way?
You might look to the org.eclipse.gef4.common.adapt package for
inspiration.
<http://wiki.eclipse.org/GEF/GEF4/Common#Adapt>
>
> Thanks
>
> Phil
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
methodhandles lookup Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-22 00:19 -0800
Re: methodhandles lookup Jeff Higgins <jeff@invalid.invalid> - 2016-01-22 08:57 +0000
Re: methodhandles lookup Jeff Higgins <jeff@invalid.invalid> - 2016-01-22 11:01 +0000
Re: methodhandles lookup Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-22 03:13 -0800
Re: methodhandles lookup Jeff Higgins <jeff@invalid.invalid> - 2016-01-22 11:43 +0000
Re: methodhandles lookup Jeff Higgins <jeff@invalid.invalid> - 2016-01-22 12:03 +0000
Re: methodhandles lookup Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-24 01:59 -0800
Re: methodhandles lookup Jeff Higgins <jeff@invalid.invalid> - 2016-01-22 12:16 +0000
Re: methodhandles lookup Jan Burse <janburse@fastmail.fm> - 2016-01-22 17:12 +0100
Re: methodhandles lookup Martin Gregorie <martin@address-in-sig.invalid> - 2016-01-22 11:27 +0000
Re: methodhandles lookup Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-01-24 01:56 -0800
Re: methodhandles lookup Jan Burse <janburse@fastmail.fm> - 2016-01-22 16:49 +0100
csiph-web