belgattitude / soluble-japha

PHP Java integration
https://belgattitude.github.io/soluble-japha/
MIT License
69 stars 15 forks source link

Add support for inner classes #38

Closed marcospassos closed 7 years ago

marcospassos commented 7 years ago

Looks like inner classes are not currently supported:

$inner = $ba->java('com.acme.ClassName.InnerClass');

Error

CreateInstance failed: new com.acme.ClassName.InnerClass. Cause: java.lang.ClassNotFoundException: com.acme.ClassName.InnerClass VM: 1.8.0_121@http://java.oracle.com/
belgattitude commented 7 years ago

Hey Marcos,

Not sure about this one, the bridge cannot implicitly make the difference between an inner class and a package namespace... and searched for the com.acme.ClassName.<RegularX>Class instead.

Can you try with the $ separator instead of the dot like this:

$inner = $ba->java('com.acme.ClassName$InnerClass');

Be sure to use single quotes, otherwise the $ sign will be interpreted on the php side.

Let me know if it works for you ? I'll update the doc accordingly.

Thanks

marcospassos commented 7 years ago

Yes, it works. I'd recommend you to make it part of the documentation.

Thank you again!

belgattitude commented 7 years ago

Hi Marcos,

Reopening the issue till the doc is fine. I've added a test case based on java.util.Calendar.Builder inner class...

See the unit test: https://github.com/belgattitude/soluble-japha/blob/master/test/src/SolubleTest/Japha/Bridge/AdapterUsageInnerClassTest.php#L46

belgattitude commented 7 years ago

Doc added in http://docs.soluble.io/soluble-japha/language_basics/#inner-classes