Comments (8)
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.
Looks like the same issue as here https://issues.apache.org/jira/browse/OGNL-250
from ognl.
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.
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.
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.
Up to you but OGNL4 can differ in this area so maybe there is no such issue there.
from ognl.
one remark: releasing OGNL3 is under my command, with OGNL4 won't be that easy ;-)
from ognl.
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)
- IllegalArgumentException when calling Ognl.getValue(Object, Object, Class) HOT 1
- Should this null-check be here? HOT 2
- Varargs method not found if no varargs are given HOT 2
- Developer Guide uses deprecated code HOT 4
- The 3.2.18 version of ognl.Ognl#getValue(..) is not easy to use at all HOT 3
- "Two vararg methods with same score" for resteasy ClientWebTarget.request() HOT 13
- Move OGNL under a dedicated organisation HOT 10
- java.lang.ArithmeticException: / by zero HOT 3
- Illegal reflective access warning when using "_parameter.containsKey() and Collections.singletonMap HOT 6
- OGNL issues with java 16 and 17 HOT 9
- Struts2 2.5 and struts2-jquery-plugin HOT 2
- In 3.3.3 (and before) compileExpression fails without add-opens on Java 17 HOT 13
- 如何解决安全问题。How ognl solve safety problem HOT 5
- Ognl.createDefaultContext(Object, ClassResolver) throws "IllegalArgumentException" HOT 4
- method with varargs invoked result exception: java.lang.ArrayStoreException HOT 6
- Most unit tests no longer running? HOT 2
- Cannot call static method through interface? HOT 8
- Request for posting of Maven signing key(s) HOT 2
- Dependency Dashboard
- Ognl choosing method on unexported class rather than exported interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ognl.