#1495 Calling overloaded Java methods

tcolar Tue 19 Apr 2011

I'm doing quite a bit of Fantom again and using lots of Java FFI.

Once again I keep running in the case where java libraries use overloading (turn out many if not most do) ... and that means i can't use those methods

I can manually making java shells with a different name.

I know at some point there was some discussion of using a facet or something to be able to "define" the right method to pick without having to have fantom actually have to "resolve it" which is slow and painful.

Did that go anywhere ?

I do seem to run into this issue frequently.

brian Tue 19 Apr 2011

Once again I keep running in the case where java libraries use overloading (turn out many if not most do) ... and that means i can't use those methods

The only restriction is that you can't subclass a Java class that does overloading, and then override an overloaded method in your subclass.

There should be nothing from stopping you from calling overloaded Java methods in your Fantom code. The compiler uses pretty much the same rules as Java to pick the right one. Although since there are implicit conversions going on, you might have to explicit cast in certain occasions.

tcolar Tue 19 Apr 2011

OK, then i don't know whats the deal, either I'm missing something or there is a bug.

I've even tried to cast/type everything, but still get an error

using [java] javax.naming
using [java] javax.naming.directory
using [java] java.lang::String
// 
InitialDirContext ctx := InitialDirContext(JavaUtils.mapToHashtable(env))
Attributes entry := BasicAttributes();
entry.put("cn", "Joh Doe2") 		
entry.put("givenName", "Joh2") 		
entry.put("sn", "Doe") 		
entry.put("uid", "jdoe") 		
oc := BasicAttribute("objectClass")
oc.add("top")
oc.add("person")
oc.add("organizationalUnit")
oc.add("inetOrgPerson")
entry.put(oc)
String str := "uid=jdoe,cn=JohnDoe,givenName=John,sn=Doe,ou=users," + baseDn
//
ctx.createSubContext(str, entry)

Error:

compile [comTsLdap]
  Compile [comTsLdap]
    FindSourceFiles [5 files]
/Users/thibaut/NetbeansProjects/comTsLdap/fan/Main.fan(40,9): Unknown method    '[java]javax.naming.directory::InitialDirContext.createSubContext'
BUILD FAILED [1254ms]!

Here is the javadoc: http://download.oracle.com/javase/1.4.2/docs/api/javax/naming/directory/InitialDirContext.html#createSubcontext(java.lang.String, javax.naming.directory.Attributes)

tcolar Tue 19 Apr 2011

Sorry .. me tired .... createSubcontext not createSubContext

vkuzkokov Tue 19 Apr 2011

createSubcontext has lowercase c

Login or Signup to reply.