You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/09/15 20:14:30 UTC

svn commit: r1523470 - in /lucene/dev/branches/branch_4x: ./ dev-tools/ dev-tools/idea/.idea/ dev-tools/idea/lucene/expressions/ dev-tools/maven/ dev-tools/maven/lucene/ dev-tools/maven/lucene/expressions/ dev-tools/scripts/ lucene/ lucene/core/ lucene...

Author: rmuir
Date: Sun Sep 15 18:14:29 2013
New Revision: 1523470

URL: http://svn.apache.org/r1523470
Log:
LUCENE-5207: lucene expressions module

Added:
    lucene/dev/branches/branch_4x/dev-tools/idea/lucene/expressions/
      - copied from r1523462, lucene/dev/trunk/dev-tools/idea/lucene/expressions/
    lucene/dev/branches/branch_4x/dev-tools/maven/lucene/expressions/
      - copied from r1523462, lucene/dev/trunk/dev-tools/maven/lucene/expressions/
    lucene/dev/branches/branch_4x/lucene/expressions/   (props changed)
      - copied from r1523462, lucene/dev/trunk/lucene/expressions/
    lucene/dev/branches/branch_4x/lucene/licenses/antlr-runtime-3.5.jar.sha1
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/antlr-runtime-3.5.jar.sha1
    lucene/dev/branches/branch_4x/lucene/licenses/antlr-runtime-LICENSE-BSD_LIKE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/antlr-runtime-LICENSE-BSD_LIKE.txt
    lucene/dev/branches/branch_4x/lucene/licenses/antlr-runtime-NOTICE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/antlr-runtime-NOTICE.txt
    lucene/dev/branches/branch_4x/lucene/licenses/asm-4.1.jar.sha1
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-4.1.jar.sha1
    lucene/dev/branches/branch_4x/lucene/licenses/asm-LICENSE-BSD_LIKE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-LICENSE-BSD_LIKE.txt
    lucene/dev/branches/branch_4x/lucene/licenses/asm-NOTICE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-NOTICE.txt
    lucene/dev/branches/branch_4x/lucene/licenses/asm-commons-4.1.jar.sha1
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-commons-4.1.jar.sha1
    lucene/dev/branches/branch_4x/lucene/licenses/asm-commons-LICENSE-BSD_LIKE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-commons-LICENSE-BSD_LIKE.txt
    lucene/dev/branches/branch_4x/lucene/licenses/asm-commons-NOTICE.txt
      - copied unchanged from r1523462, lucene/dev/trunk/lucene/licenses/asm-commons-NOTICE.txt
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/idea/.idea/modules.xml
    lucene/dev/branches/branch_4x/dev-tools/maven/lucene/pom.xml.template
    lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template
    lucene/dev/branches/branch_4x/dev-tools/scripts/smokeTestRelease.py
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/build.xml   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/common-build.xml   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
    lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java
    lucene/dev/branches/branch_4x/lucene/expressions/lib/   (props changed)
    lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
    lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java
    lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java
    lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java
    lucene/dev/branches/branch_4x/lucene/highlighter/   (props changed)
    lucene/dev/branches/branch_4x/lucene/licenses/   (props changed)
    lucene/dev/branches/branch_4x/lucene/module-build.xml   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/example/   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/   (props changed)

Modified: lucene/dev/branches/branch_4x/dev-tools/idea/.idea/modules.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/idea/.idea/modules.xml?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/idea/.idea/modules.xml (original)
+++ lucene/dev/branches/branch_4x/dev-tools/idea/.idea/modules.xml Sun Sep 15 18:14:29 2013
@@ -23,6 +23,7 @@
       <module filepath="$PROJECT_DIR$/lucene/codecs/src/test/codecs-tests.iml" />
       <module filepath="$PROJECT_DIR$/lucene/codecs/src/resources/codecs-resources.iml" />
       <module filepath="$PROJECT_DIR$/lucene/demo/demo.iml" />
+      <module filepath="$PROJECT_DIR$/lucene/expressions/expressions.iml" />
       <module filepath="$PROJECT_DIR$/lucene/facet/facet.iml" />
       <module filepath="$PROJECT_DIR$/lucene/grouping/grouping.iml" />
       <module filepath="$PROJECT_DIR$/lucene/highlighter/highlighter.iml" />

Modified: lucene/dev/branches/branch_4x/dev-tools/maven/lucene/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/lucene/pom.xml.template?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/lucene/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/lucene/pom.xml.template Sun Sep 15 18:14:29 2013
@@ -47,6 +47,7 @@
     <module>benchmark</module>
     <module>classification</module>
     <module>demo</module>
+    <module>expressions</module>
     <module>facet</module>
     <module>grouping</module>
     <module>highlighter</module>

Modified: lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template (original)
+++ lucene/dev/branches/branch_4x/dev-tools/maven/pom.xml.template Sun Sep 15 18:14:29 2013
@@ -266,6 +266,32 @@
         </exclusions>
       </dependency>
       <dependency>
+        <groupId>org.antlr</groupId>
+        <artifactId>antlr-runtime</artifactId>
+        <version>3.5</version>
+        <!-- these are dependencies to compile antlr-runtime itself -->
+        <exclusions>
+          <exclusion>
+            <groupId>antlr</groupId>
+            <artifactId>antlr</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.antlr</groupId>
+            <artifactId>stringtemplate</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.ow2.asm</groupId>
+        <artifactId>asm</artifactId>
+        <version>4.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.ow2.asm</groupId>
+        <artifactId>asm-commons</artifactId>
+        <version>4.1</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.ant</groupId>
         <artifactId>ant</artifactId>
         <version>1.8.2</version>

Modified: lucene/dev/branches/branch_4x/dev-tools/scripts/smokeTestRelease.py
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/dev-tools/scripts/smokeTestRelease.py?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/dev-tools/scripts/smokeTestRelease.py (original)
+++ lucene/dev/branches/branch_4x/dev-tools/scripts/smokeTestRelease.py Sun Sep 15 18:14:29 2013
@@ -660,7 +660,7 @@ def verifyUnpacked(project, artifact, un
 
   if project == 'lucene':
     # TODO: clean this up to not be a list of modules that we must maintain
-    extras = ('analysis', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'facet', 'grouping', 'highlighter', 'join', 'memory', 'misc', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial', 'suggest', 'test-framework', 'licenses')
+    extras = ('analysis', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'memory', 'misc', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial', 'suggest', 'test-framework', 'licenses')
     if isSrc:
       extras += ('build.xml', 'common-build.xml', 'module-build.xml', 'ivy-settings.xml', 'backwards', 'tools', 'site')
   else:

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Sun Sep 15 18:14:29 2013
@@ -16,6 +16,10 @@ New Features
   String is too restrictive (Robert Muir, Shai Erera, Mike
   McCandless)
 
+* LUCENE-5207: Added expressions module for customizing ranking
+  with script-like syntax. 
+  (Jack Conradson, Ryan Ernst, Uwe Schindler via Robert Muir)
+
 Bug Fixes
 
 * LUCENE-4998: Fixed a few places to pass IOContext.READONCE instead

Modified: lucene/dev/branches/branch_4x/lucene/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/build.xml?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/build.xml Sun Sep 15 18:14:29 2013
@@ -282,6 +282,7 @@
     <!-- codecs: problems -->
     <!-- core: problems -->
     <check-missing-javadocs dir="build/docs/demo" level="method"/>
+    <check-missing-javadocs dir="build/docs/expressions" level="method"/>
     <!-- facet: problems -->
     <!-- grouping: problems -->
     <!-- highlighter: problems -->

Modified: lucene/dev/branches/branch_4x/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/common-build.xml?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/common-build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/common-build.xml Sun Sep 15 18:14:29 2013
@@ -1570,6 +1570,8 @@ ${tests-output}/junit4-*.suites     - pe
         <pattern substring="This file was generated automatically by the Snowball to Java compiler"/>
       <!-- uima tests generated by JCasGen -->
         <pattern substring="First created by JCasGen"/>
+      <!-- parsers generated by antlr -->
+        <pattern substring="ANTLR GENERATED CODE"/>
       </rat:substringMatcher>
 
       <!-- built in approved licenses -->

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/util/MathUtil.java Sun Sep 15 18:14:29 2013
@@ -44,6 +44,13 @@ public final class MathUtil {
     return ret;
   }
 
+  /**
+   * Calculates logarithm in a given base with doubles.
+   */
+  public static double log(double base, double x) {
+    return Math.log(x) / Math.log(base);
+  }
+
   /** Return the greatest common divisor of <code>a</code> and <code>b</code>,
    *  consistently with {@link BigInteger#gcd(BigInteger)}.
    *  <p><b>NOTE</b>: A greatest common divisor must be positive, but
@@ -78,4 +85,69 @@ public final class MathUtil {
     }
     return a << commonTrailingZeros;
   }
+
+
+  /**
+   * Calculates inverse hyperbolic sine of a {@code double} value.
+   * <p>
+   * Special cases:
+   * <ul>
+   *    <li>If the argument is NaN, then the result is NaN.
+   *    <li>If the argument is zero, then the result is a zero with the same sign as the argument.
+   *    <li>If the argument is infinite, then the result is infinity with the same sign as the argument.
+   * </ul>
+   */
+  public static double asinh(double a) {
+    final double sign;
+    // check the sign bit of the raw representation to handle -0
+    if (Double.doubleToRawLongBits(a) < 0) {
+      a = Math.abs(a);
+      sign = -1.0d;
+    } else {
+      sign = 1.0d;
+    }
+
+    return sign * Math.log(Math.sqrt(a * a + 1.0d) + a);
+  }
+
+  /**
+   * Calculates inverse hyperbolic cosine of a {@code double} value.
+   * <p>
+   * Special cases:
+   * <ul>
+   *    <li>If the argument is NaN, then the result is NaN.
+   *    <li>If the argument is +1, then the result is a zero.
+   *    <li>If the argument is positive infinity, then the result is positive infinity.
+   *    <li>If the argument is less than 1, then the result is NaN.
+   * </ul>
+   */
+  public static double acosh(double a) {
+    return Math.log(Math.sqrt(a * a - 1.0d) + a);
+  }
+
+  /**
+   * Calculates inverse hyperbolic tangent of a {@code double} value.
+   * <p>
+   * Special cases:
+   * <ul>
+   *    <li>If the argument is NaN, then the result is NaN.
+   *    <li>If the argument is zero, then the result is a zero with the same sign as the argument.
+   *    <li>If the argument is +1, then the result is positive infinity.
+   *    <li>If the argument is -1, then the result is negative infinity.
+   *    <li>If the argument's absolute value is greater than 1, then the result is NaN.
+   * </ul>
+   */
+  public static double atanh(double a) {
+    final double mult;
+    // check the sign bit of the raw representation to handle -0
+    if (Double.doubleToRawLongBits(a) < 0) {
+      a = Math.abs(a);
+      mult = -0.5d;
+    } else {
+      mult = 0.5d;
+    }
+    return mult * Math.log((1.0d + a) / (1.0d - a));
+  }
+
+
 }

Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java Sun Sep 15 18:14:29 2013
@@ -102,4 +102,80 @@ public class TestMathUtil extends Lucene
     assertEquals(Long.MIN_VALUE, MathUtil.gcd(Long.MIN_VALUE, Long.MIN_VALUE));
   }
 
+  public void testAcoshMethod() {
+    // acosh(NaN) == NaN
+    assertTrue(Double.isNaN(MathUtil.acosh(Double.NaN)));
+    // acosh(1) == +0
+    assertEquals(0, Double.doubleToLongBits(MathUtil.acosh(1D)));
+    // acosh(POSITIVE_INFINITY) == POSITIVE_INFINITY
+    assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+        Double.doubleToLongBits(MathUtil.acosh(Double.POSITIVE_INFINITY)));
+    // acosh(x) : x < 1 == NaN
+    assertTrue(Double.isNaN(MathUtil.acosh(0.9D)));                      // x < 1
+    assertTrue(Double.isNaN(MathUtil.acosh(0D)));                        // x == 0
+    assertTrue(Double.isNaN(MathUtil.acosh(-0D)));                       // x == -0
+    assertTrue(Double.isNaN(MathUtil.acosh(-0.9D)));                     // x < 0
+    assertTrue(Double.isNaN(MathUtil.acosh(-1D)));                       // x == -1
+    assertTrue(Double.isNaN(MathUtil.acosh(-10D)));                      // x < -1
+    assertTrue(Double.isNaN(MathUtil.acosh(Double.NEGATIVE_INFINITY)));  // x == -Inf
+
+    double epsilon = 0.000001;
+    assertEquals(0, MathUtil.acosh(1), epsilon);
+    assertEquals(1.5667992369724109, MathUtil.acosh(2.5), epsilon);
+    assertEquals(14.719378760739708, MathUtil.acosh(1234567.89), epsilon);
+  }
+
+  public void testAsinhMethod() {
+
+    // asinh(NaN) == NaN
+    assertTrue(Double.isNaN(MathUtil.asinh(Double.NaN)));
+    // asinh(+0) == +0
+    assertEquals(0, Double.doubleToLongBits(MathUtil.asinh(0D)));
+    // asinh(-0) == -0
+    assertEquals(Double.doubleToLongBits(-0D), Double.doubleToLongBits(MathUtil.asinh(-0D)));
+    // asinh(POSITIVE_INFINITY) == POSITIVE_INFINITY
+    assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+        Double.doubleToLongBits(MathUtil.asinh(Double.POSITIVE_INFINITY)));
+    // asinh(NEGATIVE_INFINITY) == NEGATIVE_INFINITY
+    assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY),
+        Double.doubleToLongBits(MathUtil.asinh(Double.NEGATIVE_INFINITY)));
+
+    double epsilon = 0.000001;
+    assertEquals(-14.719378760740035, MathUtil.asinh(-1234567.89), epsilon);
+    assertEquals(-1.6472311463710958, MathUtil.asinh(-2.5), epsilon);
+    assertEquals(-0.8813735870195429, MathUtil.asinh(-1), epsilon);
+    assertEquals(0, MathUtil.asinh(0), 0);
+    assertEquals(0.8813735870195429, MathUtil.asinh(1), epsilon);
+    assertEquals(1.6472311463710958, MathUtil.asinh(2.5), epsilon);
+    assertEquals(14.719378760740035, MathUtil.asinh(1234567.89), epsilon  );
+  }
+
+  public void testAtanhMethod() {
+    // atanh(NaN) == NaN
+    assertTrue(Double.isNaN(MathUtil.atanh(Double.NaN)));
+    // atanh(+0) == +0
+    assertEquals(0, Double.doubleToLongBits(MathUtil.atanh(0D)));
+    // atanh(-0) == -0
+    assertEquals(Double.doubleToLongBits(-0D),
+        Double.doubleToLongBits(MathUtil.atanh(-0D)));
+    // atanh(1) == POSITIVE_INFINITY
+    assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+        Double.doubleToLongBits(MathUtil.atanh(1D)));
+    // atanh(-1) == NEGATIVE_INFINITY
+    assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY),
+        Double.doubleToLongBits(MathUtil.atanh(-1D)));
+    // atanh(x) : Math.abs(x) > 1 == NaN
+    assertTrue(Double.isNaN(MathUtil.atanh(1.1D)));                      // x > 1
+    assertTrue(Double.isNaN(MathUtil.atanh(Double.POSITIVE_INFINITY)));  // x == Inf
+    assertTrue(Double.isNaN(MathUtil.atanh(-1.1D)));                     // x < -1
+    assertTrue(Double.isNaN(MathUtil.atanh(Double.NEGATIVE_INFINITY)));  // x == -Inf
+
+    double epsilon = 0.000001;
+    assertEquals(Double.NEGATIVE_INFINITY, MathUtil.atanh(-1), 0);
+    assertEquals(-0.5493061443340549, MathUtil.atanh(-0.5), epsilon);
+    assertEquals(0, MathUtil.atanh(0), 0);
+    assertEquals(0.5493061443340549, MathUtil.atanh(0.5), epsilon);
+    assertEquals(Double.POSITIVE_INFINITY, MathUtil.atanh(1), 0);
+  }
+
 }

Modified: lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java?rev=1523470&r1=1523462&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java Sun Sep 15 18:14:29 2013
@@ -58,7 +58,7 @@ import org.objectweb.asm.commons.Generat
  * You can compile with an alternate set of functions via {@link #compile(String, Map, ClassLoader)}.
  * For example:
  * <pre class="prettyprint">
- *   Map&lt;String,Method&gt; functions = new HashMap&lt;&gt;();
+ *   Map&lt;String,Method&gt; functions = new HashMap&lt;String,Method&gt;();
  *   // add all the default functions
  *   functions.putAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
  *   // add cbrt()
@@ -73,7 +73,7 @@ import org.objectweb.asm.commons.Generat
  */
 public class JavascriptCompiler {
 
-  static class Loader extends ClassLoader {
+  static final class Loader extends ClassLoader {
     Loader(ClassLoader parent) {
       super(parent);
     }
@@ -83,7 +83,7 @@ public class JavascriptCompiler {
     }
   }
   
-  private static final int CLASSFILE_VERSION = Opcodes.V1_7;
+  private static final int CLASSFILE_VERSION = Opcodes.V1_6;
   
   // We use the same class name for all generated classes as they all have their own class loader.
   // The source code is displayed as "source file name" in stack trace.
@@ -197,7 +197,13 @@ public class JavascriptCompiler {
         .define(COMPILED_EXPRESSION_CLASS, classWriter.toByteArray());
       Constructor<? extends Expression> constructor = evaluatorClass.getConstructor(String.class, String[].class);
       return constructor.newInstance(sourceText, externalsMap.keySet().toArray(new String[externalsMap.size()]));
-    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
+    } catch (InstantiationException exception) {
+      throw new IllegalStateException("An internal error occurred attempting to compile the expression (" + sourceText + ").", exception);
+    } catch (IllegalAccessException exception) {
+      throw new IllegalStateException("An internal error occurred attempting to compile the expression (" + sourceText + ").", exception);
+    } catch (NoSuchMethodException exception) {
+      throw new IllegalStateException("An internal error occurred attempting to compile the expression (" + sourceText + ").", exception);
+    } catch (InvocationTargetException exception) {
       throw new IllegalStateException("An internal error occurred attempting to compile the expression (" + sourceText + ").", exception);
     }
   }
@@ -500,12 +506,12 @@ public class JavascriptCompiler {
   public static final Map<String,Method> DEFAULT_FUNCTIONS;
   static {
     Map<String,Method> map = new HashMap<String,Method>();
+    Reader in = null;
     try {
       final Properties props = new Properties();
-      try (Reader in = IOUtils.getDecodingReader(JavascriptCompiler.class,
-        JavascriptCompiler.class.getSimpleName() + ".properties", IOUtils.CHARSET_UTF_8)) {
-        props.load(in);
-      }
+      in = IOUtils.getDecodingReader(JavascriptCompiler.class,
+        JavascriptCompiler.class.getSimpleName() + ".properties", IOUtils.CHARSET_UTF_8);
+      props.load(in);
       for (final String call : props.stringPropertyNames()) {
         final String[] vals = props.getProperty(call).split(",");
         if (vals.length != 3) {
@@ -520,8 +526,14 @@ public class JavascriptCompiler {
         checkFunction(method, JavascriptCompiler.class.getClassLoader());
         map.put(call, method);
       }
-    } catch (NoSuchMethodException | ClassNotFoundException | IOException e) {
+    } catch (NoSuchMethodException e) {
+      throw new Error("Cannot resolve function", e);
+    } catch (ClassNotFoundException e) {
+      throw new Error("Cannot resolve function", e);
+    } catch (IOException e) {
       throw new Error("Cannot resolve function", e);
+    } finally {
+      IOUtils.closeWhileHandlingException(in);
     }
     DEFAULT_FUNCTIONS = Collections.unmodifiableMap(map);
   }

Modified: lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java?rev=1523470&r1=1523462&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java (original)
+++ lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestDemoExpressions.java Sun Sep 15 18:14:29 2013
@@ -17,6 +17,7 @@ import org.apache.lucene.search.TermQuer
 import org.apache.lucene.search.TopFieldDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -36,6 +37,7 @@ import org.apache.lucene.util.LuceneTest
  */
 
 /** simple demo of using expressions */
+@SuppressCodecs("Lucene3x")
 public class  TestDemoExpressions extends LuceneTestCase {
   IndexSearcher searcher;
   DirectoryReader reader;

Modified: lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java?rev=1523470&r1=1523462&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java (original)
+++ lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSorts.java Sun Sep 15 18:14:29 2013
@@ -48,11 +48,13 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.English;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
 
 /**
  * Tests some basic expressions against different queries,
  * and fieldcache/docvalues fields against an equivalent sort.
  */
+@SuppressCodecs("Lucene3x")
 public class TestExpressionSorts extends LuceneTestCase {
   private Directory dir;
   private IndexReader reader;

Modified: lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java?rev=1523470&r1=1523462&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java (original)
+++ lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/js/TestCustomFunctions.java Sun Sep 15 18:14:29 2013
@@ -163,7 +163,7 @@ public class TestCustomFunctions extends
   }
   
   /** Classloader that can be used to create a fake static class that has one method returning a static var */
-  static class Loader extends ClassLoader implements Opcodes {
+  static final class Loader extends ClassLoader implements Opcodes {
     Loader(ClassLoader parent) {
       super(parent);
     }
@@ -218,7 +218,7 @@ public class TestCustomFunctions extends
     }
     
     // mix foreign and default functions
-    Map<String,Method> mixedFunctions = new HashMap<>(JavascriptCompiler.DEFAULT_FUNCTIONS);
+    Map<String,Method> mixedFunctions = new HashMap<String,Method>(JavascriptCompiler.DEFAULT_FUNCTIONS);
     mixedFunctions.putAll(functions);
     expr = JavascriptCompiler.compile("bar()", mixedFunctions, childLoader);
     assertEquals(2.0, expr.evaluate(0, null), DELTA);
@@ -227,7 +227,7 @@ public class TestCustomFunctions extends
     
     // use our classloader, not the foreign one, which should fail!
     try {
-      JavascriptCompiler.compile("bar()", functions, thisLoader);
+      JavascriptCompiler.compile("bar()", mixedFunctions, thisLoader);
       fail();
     } catch (IllegalArgumentException e) {
       assertTrue(e.getMessage().contains("is not declared by a class which is accessible by the given parent ClassLoader"));

Modified: lucene/dev/branches/branch_4x/lucene/module-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/module-build.xml?rev=1523470&r1=1523469&r2=1523470&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/module-build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/module-build.xml Sun Sep 15 18:14:29 2013
@@ -433,6 +433,28 @@
     <property name="codecs-javadocs.uptodate" value="true"/>
   </target>
 
+  <property name="expressions.jar" value="${common.dir}/build/expressions/lucene-expressions-${version}.jar"/>
+  <target name="check-expressions-uptodate" unless="expressions.uptodate">
+    <module-uptodate name="expressions" jarfile="${expressions.jar}" property="expressions.uptodate"/>
+  </target>
+  <target name="jar-expressions" unless="expressions.uptodate" depends="check-expressions-uptodate">
+    <ant dir="${common.dir}/expressions" target="jar-core" inheritAll="false">
+      <propertyset refid="uptodate.and.compiled.properties"/>
+    </ant>
+    <property name="expressions.uptodate" value="true"/>
+  </target>
+
+  <property name="expressions-javadoc.jar" value="${common.dir}/build/expressions/lucene-expressions-${version}-javadoc.jar"/>
+  <target name="check-expressions-javadocs-uptodate" unless="expressions-javadocs.uptodate">
+    <module-uptodate name="expressions" jarfile="${expressions-javadoc.jar}" property="expressions-javadocs.uptodate"/>
+  </target>
+  <target name="javadocs-expressions" unless="expressions-javadocs.uptodate" depends="check-expressions-javadocs-uptodate">
+    <ant dir="${common.dir}/expressions" target="javadocs" inheritAll="false">
+      <propertyset refid="uptodate.and.compiled.properties"/>
+    </ant>
+    <property name="expressions-javadocs.uptodate" value="true"/>
+  </target>
+
   <property name="grouping.jar" value="${common.dir}/build/grouping/lucene-grouping-${version}.jar"/>
   <target name="check-grouping-uptodate" unless="grouping.uptodate">
     <module-uptodate name="grouping" jarfile="${grouping.jar}" property="grouping.uptodate"/>