You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Uwe Schindler (JIRA)" <ji...@apache.org> on 2015/12/05 01:40:10 UTC

[jira] [Created] (LUCENE-6920) Simplify callable function checks in Expression module

Uwe Schindler created LUCENE-6920:
-------------------------------------

             Summary: Simplify callable function checks in Expression module
                 Key: LUCENE-6920
                 URL: https://issues.apache.org/jira/browse/LUCENE-6920
             Project: Lucene - Core
          Issue Type: Improvement
          Components: modules/expressions
            Reporter: Uwe Schindler
            Assignee: Uwe Schindler
             Fix For: Trunk, 5.5


The expressions module allows to specify custom functions. It does some checks to ensure that the compiled Expression works correctly and does not produce linkage errors. It also checks parameters and return type to  be doubles.

There are two problems with the current approach:
- the check gets classloaders of the method's declaring class. This fails if a security manager forbids access to bootstrap classes (e.g., java.lang.Math)
- the code only checks if method or declaring class are public, but not if it is really reachable. This may not be the case in Java 9 (different module without exports,...)

This issue will use MethodHandles to do the accessibility checks (it uses MethodHandles.publicLookup() to resolve the given reflected method). If that fails, our compiled code cannot acess it. If module system prevents access, this is also checked.

To fix the issue with classloaders, it uses a trick: It calls Class.forName() with the classloader we use to compile our expression. If that does not return the same class as the declared method, it also fails compilation. This prevents NoClassDefFoundException on executing the expression.

All tests pass.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org