diff --git a/src/main/java/carpet/script/annotation/AnnotationParser.java b/src/main/java/carpet/script/annotation/AnnotationParser.java
index 987ecb0c..a2c759c6 100644
--- a/src/main/java/carpet/script/annotation/AnnotationParser.java
+++ b/src/main/java/carpet/script/annotation/AnnotationParser.java
@@ -84,9 +84,8 @@ public final class AnnotationParser
*
There is a set of requirements for the class and its methods:
*
* - Class must be concrete. That is, no interfaces or abstract classes should be passed
- * - Class must have the default constructor (or an equivalent) available. That is done in order to not need the {@code static} modifier in every method, making them faster to
- * code and simpler to look at.
- * - Annotated methods must not be {@code static}. See claim above
+ * - Class must have the default constructor (or an equivalent) available. That is done in order to not need the {@code static} modifier in every
+ * method, making them faster to code and simpler to look at.
* - Annotated methods must not throw checked exceptions. They can throw regular {@link RuntimeException}s (including but not limited to
* {@link InternalExpressionException}).
* Basically, it's fine as long as you don't add a {@code throws} declaration to your methods.
@@ -121,9 +120,7 @@ public final class AnnotationParser
{
if (!method.isAnnotationPresent(ScarpetFunction.class))
continue;
- // Checks
- if (Modifier.isStatic(method.getModifiers()))
- throw new IllegalArgumentException("Annotated method '" + method.getName() + "', provided in '" + clazz + "' must not be static");
+
if (method.getExceptionTypes().length != 0)
throw new IllegalArgumentException("Annotated method '" + method.getName() +"', provided in '"+clazz+"' must not declare checked exceptions");
@@ -212,7 +209,8 @@ public final class AnnotationParser
try
{
MethodHandle tempHandle = MethodHandles.publicLookup().unreflect(method).asFixedArity().asSpreader(Object[].class, this.methodParamCount);
- this.handle = tempHandle.asType(tempHandle.type().changeReturnType(Object.class)).bindTo(instance);
+ tempHandle = tempHandle.asType(tempHandle.type().changeReturnType(Object.class));
+ this.handle = Modifier.isStatic(method.getModifiers()) ? tempHandle : tempHandle.bindTo(instance);
} catch (IllegalAccessException e)
{
throw new IllegalArgumentException(e);
diff --git a/src/main/java/carpet/script/annotation/Param.java b/src/main/java/carpet/script/annotation/Param.java
index 9d28ea1f..343189e7 100644
--- a/src/main/java/carpet/script/annotation/Param.java
+++ b/src/main/java/carpet/script/annotation/Param.java
@@ -133,42 +133,14 @@ public interface Param
/**
* Class that holds the actual converters and converter getting logic for those annotated types and things.
*
- * It also holds the registry for strict {@link ValueConverter}s.
+ * It also holds the registry for strict and custom {@link ValueConverter}s.
*
* @see #registerStrictConverter(Class, boolean, ValueConverter)
+ * @see #registerCustomConverterFactory(BiFunction)
*
*/
public static final class Params
{
- /**
- * A {@link ValueConverter} that outputs the given {@link LazyValue} when running {@link #checkAndConvert(Iterator, Context, Context.Type)}, and
- * throws {@link UnsupportedOperationException} when trying to convert a {@link Value} directly.
- *
- * Public in order to allow custom {@link ValueConverter} to check whether values should be evaluated while testing conditions.
- */
- /*public static final ValueConverter LAZY_VALUE_IDENTITY = new ValueConverter()
- { // No longer possible
-
- @Override
- public LazyValue convert(Value val)
- {
- throw new UnsupportedOperationException(
- "Called convert() with a Value in LazyValue identity, where only evalAndConvert is supported");
- }
-
- @Override
- public LazyValue checkAndConvert(Iterator lazyValueIterator, Context c, Context.Type theLazyT)
- {
- return lazyValueIterator.hasNext() ? lazyValueIterator.next() : null;
- }
-
- @Override
- public String getTypeName()
- {
- return "something";
- }
- };*/
-
/**
* A {@link ValueConverter} that outputs the {@link Context} in which the function has been called, and throws {@link UnsupportedOperationException} when trying to convert a {@link Value}
* directly.
@@ -228,7 +200,7 @@ public interface Param
*
* Stored as {@code , Converter>}
*/
- private static Map, Boolean>, ValueConverter>> strictParamsByClassAndShallowness = new HashMap<>();
+ private static final Map, Boolean>, ValueConverter>> strictParamsByClassAndShallowness = new HashMap<>();
static
{ // TODO Specify strictness in name?
registerStrictConverter(String.class, false, new SimpleTypeConverter<>(StringValue.class, StringValue::getString, "string"));
@@ -279,7 +251,7 @@ public interface Param
strictParamsByClassAndShallowness.put(key, converter);
}
- private static List, ValueConverter>>> customFactories = new ArrayList<>();
+ private static final List, ValueConverter>>> customFactories = new ArrayList<>();
/**
* Allows extensions to register COMPLEX {@link ValueConverter} factories in order to be used with the {@link Param.Custom}
diff --git a/src/main/java/carpet/script/annotation/ScarpetFunction.java b/src/main/java/carpet/script/annotation/ScarpetFunction.java
index 80aa94de..466bda7e 100644
--- a/src/main/java/carpet/script/annotation/ScarpetFunction.java
+++ b/src/main/java/carpet/script/annotation/ScarpetFunction.java
@@ -29,7 +29,7 @@ import carpet.script.value.Value;
* {@link AnnotationParser#parseFunctionClass(Class)} ONCE. The provided {@link Class} must be concrete and provide the default constructor or an
* equivalent to it.
*
- * Methods annotated with this annotation must not be static and must not declare throwing any checked exceptions.
+ * Methods annotated with this annotation must not declare throwing any checked exceptions.
*
* If one of the method's parameters is {@link Context}, Carpet will pass the actual {@link Context} of the expression to the
* method. If one of the method's parameters is {@link Context.Type}, Carpet will pass the Context Type the function was called inside. That