Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.painless;

public class StaticTest {
public static int staticAddIntsTest(int x, int y) {
return x + y;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,6 @@ public void addImportedPainlessMethod(Class<?> targetClass, String methodName, C
"invalid imported method name [" + methodName + "] for target class [" + targetCanonicalClassName + "].");
}

PainlessClassBuilder painlessClassBuilder = classesToPainlessClassBuilders.get(targetClass);

if (painlessClassBuilder == null) {
throw new IllegalArgumentException("target class [" + targetCanonicalClassName + "] not found for imported method " +
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + typesToCanonicalTypeNames(typeParameters) + "]");
}

int typeParametersSize = typeParameters.size();
List<Class<?>> javaTypeParameters = new ArrayList<>(typeParametersSize);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class org.elasticsearch.painless.FeatureTest no_import {

# for testing
static_import {
int staticAddIntsTest(int, int) from_class org.elasticsearch.painless.StaticTest
float staticAddFloatsTest(float, float) from_class org.elasticsearch.painless.FeatureTest
int testAddWithState(int, int, int, double) bound_to org.elasticsearch.painless.BindingTest
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void testNoSemicolon() {
}

public void testStatic() {
assertEquals(10, exec("staticAddIntsTest(7, 3)"));
assertEquals(15.5f, exec("staticAddFloatsTest(6.5f, 9.0f)"));
}
}