Giter VIP home page Giter VIP logo

Comments (8)

marvkis avatar marvkis commented on August 12, 2024

I did a short test to see how the matching for java itself behaves:

    public static void main(String[] args) {
        Messages messages = new Messages(new HashMap<Object, Object>());
        System.out.println("messages.format('ShowAllCount', one) => \"foo\" == "+messages.format("ShowAllCount", 1 )); 
        System.out.println("messages.format('ShowAllCount', {one}) => \"foo\" == "+messages.format("ShowAllCount", new Object[] { 1 } )); 
        System.out.println("messages.format('ShowAllCount', {one, two}) => \"foo\" == "+messages.format("ShowAllCount", new Object[] { 1, 2 } )); 
        System.out.println("messages.format('ShowAllCount', one, two) => \"foo\" == "+messages.format("ShowAllCount", 1, 2 )); 
    }

The result is:

messages.format('ShowAllCount', one) => "foo" == first
messages.format('ShowAllCount', {one}) => "foo" == foo
messages.format('ShowAllCount', {one, two}) => "foo" == foo
messages.format('ShowAllCount', one, two) => "foo" == haha

And this is the same for both java versions (1.7 & 1.8). So this would be the ideal result ;)

from ognl.

lukaszlenart avatar lukaszlenart commented on August 12, 2024

Looks like the same issue as here https://issues.apache.org/jira/browse/OGNL-250

from ognl.

marvkis avatar marvkis commented on August 12, 2024

Hi @lukaszlenart ,
Thank you for this link. I havn't been aware that the OGNL project on apache is still alive ;)

Never the less I started digging a bit deeper into it (also in conjunction with #17 ) and it seems that there are two seperate implementations for finding out the appropiate method:
OgnlRuntime.getReadMethod() used by the compiler and OgnlRuntime.getAppropriateMethod() in other cases.

Might it make sense to centralize it to one implementation?

I also have seen that methods are actually called during the compile(). Are you aware of this? Dosn't it cause a lot of confusion in the backend?

And should wie transfer my tickets to Apache?

from ognl.

lukaszlenart avatar lukaszlenart commented on August 12, 2024

Yes, I mean, soon I want to switch all the efforts to Apache Commons OGNL and start preparing a new 4.0 release. I don't want to spend more time on extending/improving 3.x line - it's here just to keep support, fix bugs and so on.

from ognl.

marvkis avatar marvkis commented on August 12, 2024

So does it make sense to fix this regressin in 3.x or shall i just fix my issue in #17 and leave this as Task for OGNL 4?

from ognl.

lukaszlenart avatar lukaszlenart commented on August 12, 2024

Up to you but OGNL4 can differ in this area so maybe there is no such issue there.

from ognl.

lukaszlenart avatar lukaszlenart commented on August 12, 2024

one remark: releasing OGNL3 is under my command, with OGNL4 won't be that easy ;-)

from ognl.

marvkis avatar marvkis commented on August 12, 2024

Hi,

I started digging into that method matching and implemented an initial version.
It works with all current unit tests and also fixes #17.

Please have a look on the code and decide what to do. It could fix a lot things but also be dangerous...

And just some ideas i had while i was working in the depth of OGNL - could be interesting for OGNL4:

It might be better to have all the Matching and Conversion stuff done on "Java-Class" basis instead of Object basis. I think this is why methods are called during OGNL.compile() - to get the returning Object. When the method is not callable or failing the compiler starts struggling.
My Opinion is that the Object is not really required. I think looking taking Method.getReturnType() and working with the class would be better provides better matching capabilties - we even know what it is if the method fails or returns null.

And as further use case - it might be passible to implement autocompletion / code assist functionality based on this for OGNL ;)

Are there already some discissions on this?

from ognl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.