You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2013/09/13 15:40:57 UTC
svn commit: r1522925 -
/lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
Author: uschindler
Date: Fri Sep 13 13:40:56 2013
New Revision: 1522925
URL: http://svn.apache.org/r1522925
Log:
LUCENE-5207: Add a unused test method to make sure that if we change the FunctionValues interface we get compile error. Also make the class format version a constant for easy maintenance (once we backport)
Modified:
lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
Modified: lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java?rev=1522925&r1=1522924&r2=1522925&view=diff
==============================================================================
--- lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java (original)
+++ lucene/dev/branches/lucene5207/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java Fri Sep 13 13:40:56 2013
@@ -116,6 +116,8 @@ public class JavascriptCompiler {
}
}
+ private static final int CLASSFILE_VERSION = V1_7;
+
// 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.
private static final String COMPILED_EXPRESSION_CLASS = JavascriptCompiler.class.getName() + "$CompiledExpression";
@@ -153,6 +155,17 @@ public class JavascriptCompiler {
}
/**
+ * This method is unused, it is just here to make sure that the funcion signatures don't change.
+ * If this method fails to compile, you also have to change the byte code generator to correctly
+ * use the FunctionValues class.
+ */
+ @SuppressWarnings("unused")
+ private static void unusedTestCompile() {
+ FunctionValues f = null;
+ double ret = f.doubleVal(2);
+ }
+
+ /**
* Constructs a compiler for expressions.
*/
private JavascriptCompiler() {
@@ -189,7 +202,7 @@ public class JavascriptCompiler {
private void beginCompile(String sourceText) {
classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
- classWriter.visit(V1_7, ACC_PUBLIC + ACC_SUPER + ACC_FINAL, COMPILED_EXPRESSION_INTERNAL,
+ classWriter.visit(CLASSFILE_VERSION, ACC_PUBLIC + ACC_SUPER + ACC_FINAL, COMPILED_EXPRESSION_INTERNAL,
null, EXPRESSION_INTERNAL, null);
String clippedSourceText = (sourceText.length() <= MAX_SOURCE_LENGTH) ? sourceText : (sourceText.substring(0, MAX_SOURCE_LENGTH - 3) + "...");
classWriter.visitSource(clippedSourceText, null);