diff --git a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ArraySerializable.java b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ArraySerializable.java index 49a901dd..aa35686d 100644 --- a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ArraySerializable.java +++ b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ArraySerializable.java @@ -195,6 +195,5 @@ public String toString() { + ",longs = " + Arrays.toString(longs) + ",booleanss = " + Arrays.deepToString(booleanss) + "}"; - } } diff --git a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ListSerializable.java b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ListSerializable.java index 47da714a..8afadea5 100644 --- a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ListSerializable.java +++ b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/ListSerializable.java @@ -9,10 +9,8 @@ import java.io.File; import java.io.IOException; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.logging.Logger; -import java.util.stream.Collectors; import xyz.janboerman.scalaloader.configurationserializable.ConfigurationSerializable; import static xyz.janboerman.scalaloader.example.java.ExamplePlugin.assertionsEnabled; diff --git a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/MapSerializable.java b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/MapSerializable.java index e1be9c23..eef0686f 100644 --- a/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/MapSerializable.java +++ b/JavaExample/src/main/java/xyz/janboerman/scalaloader/example/java/MapSerializable.java @@ -8,7 +8,6 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import java.util.EnumMap; import java.util.Map; import java.util.Objects; diff --git a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/ParameterType.java b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/ParameterType.java index 0bc4cfd3..64f903e9 100644 --- a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/ParameterType.java +++ b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/ParameterType.java @@ -129,7 +129,7 @@ public static ParameterType from(Set annotations, Type typ return from(annotations, upperBound); } else { //this branch should never be taken actually. - //when it is take, TypeUtils.asRawType will throw an IllegalArgumentException + //when it is taken, TypeUtils.asRawType will throw an IllegalArgumentException. return new ParameterType(annotations, TypeUtils.asRawType(type)); } } diff --git a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/types/ScalaCollection.java b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/types/ScalaCollection.java index 1e6a4d19..e654ab97 100644 --- a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/types/ScalaCollection.java +++ b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/runtime/types/ScalaCollection.java @@ -32,6 +32,7 @@ public abstract class ScalaCollection { static final String SCALA_MUTABLE_ARRAY_SEQ = "scala.collection.mutable.ArraySeq"; static final String SCALA_IMMUTABLE_LIST = "scala.collection.immutable.List"; //TODO static final String SCALA_IMMUTABLE_NUMERIC_RANGE = "scala.collection.immutable.NumericRange"; //can't handle this (yet), because we need to obtain the Integral instances first. + //TODO but we have Explicit now. does this help us? //TODO also need to special-case the 'sorted' collections: TreeSet etc public ScalaCollection() {} @@ -211,6 +212,7 @@ public String toString() { } //TODO do I still need this? +//TODO I think we want to generate this code, amiright? @SerializableAs("THE_SEQ_IMPLEMENTATION_CLASS_NAME") /*public*/ final class SeqAdapter extends ScalaSeq { private final scala.collection.Seq seq; diff --git a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/transform/Conversions.java b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/transform/Conversions.java index 745a78d0..3c961f3c 100644 --- a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/transform/Conversions.java +++ b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/configurationserializable/transform/Conversions.java @@ -153,7 +153,7 @@ else if (ScalaConversions.isScalaCollection(typeSignature, (ClassLoader) pluginC methodVisitor.visitMethodInsn(INVOKEVIRTUAL, "java/util/UUID", "toString", "()Ljava/lang/String;", false); operandStack.replaceTop(STRING_TYPE); break; - //TODO java.util.Date maybe? anything else? + //TODO java.util.Date/java.time.Instant maybe? //TODO scala.math.BigInt //TODO scala.math.BigDecimal @@ -1811,6 +1811,7 @@ static void serializeCollection(IScalaPluginClassLoader classLoader, MethodVisit //TODO if I really feel ambitious, I might implement recursive lookups too! //TODO I should probably factor this out to a separate "ImplicitSearch" class. + //TODO a humble beginning is started in the 'Explicit.java' file. } @@ -1820,7 +1821,6 @@ static void serializeCollection(IScalaPluginClassLoader classLoader, MethodVisit //TODO - immutable.NumericRange --- done! (but not yet tested) //TODO - immutable.ArraySeq //TODO - mutable.ArraySeq - //TODO - mutable.ArrayBuilder (debatable) //TODO @@ -2202,11 +2202,12 @@ static void deserializeCollection(IScalaPluginClassLoader classLoader, MethodVis //TODO - immutable.NumericRange --- TODO requires ImplicitSearch for deserialization. //TODO --- TODO Also we need to generate instanceof bytecodes to check the runtime type of the elements //TODO --- TODO and use the correct component types for the start, end and step values of the NumericRange. - //TODO - immutable.ArraySeq - //TODO - mutable.ArraySeq - //TODO - mutable.ArrayBuilder (debatable) + //TODO --- TODO implement this later after the other types are done. + //TODO - immutable.ArraySeq --- TODO why does this need a special case? because the ArraySeq is potentially backed by primitive arrays. and for the case of Unit we only have to save a length. boolean arrays can be backed by a long (where the bits equal booleans). + //TODO - mutable.ArraySeq --- TODO why does this need a special case? Do we have a custom serialization strategy? I think we do! We could also re-use our array serialisation code. //TODO + // //best effort final TypeSignature elementTypeSignature = typeSignature.hasTypeArguments() ? typeSignature.getTypeArgument(0) : TypeSignature.OBJECT_TYPE_SIGNATURE; @@ -2318,7 +2319,7 @@ private static void generateNewBuilderCall(IScalaPluginClassLoader classLoader, } private static void generateOrdering(IScalaPluginClassLoader classLoader, MethodVisitor methodVisitor, TypeSignature elementType, LocalCounter localCounter, LocalVariableTable localVariableTable, OperandStack operandStack) { - switch(elementType.internalName()) { + switch (elementType.internalName()) { //java primitives case "B": methodVisitor.visitFieldInsn(GETSTATIC, "scala/math/Ordering$Byte$", "MODULE$", "Lscala/math/Ordering$Byte$;"); @@ -2462,6 +2463,7 @@ private static void generateOrdering(IScalaPluginClassLoader classLoader, Method //assume the Ordering instance can be found in the companion object. //TODO we need to inspect the fields & methods of the companion object and generate the appropriate calls! //TODO need to Adjust GlobalScanner or something so that CompanionObjectScanResult is part of the result? + //TODO can we use Explicit here? break; } diff --git a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/explicit/Explicit.java b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/explicit/Explicit.java index 0fcb4765..495cda4a 100644 --- a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/explicit/Explicit.java +++ b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/explicit/Explicit.java @@ -179,6 +179,8 @@ public static Object getTypeClassInstance(Class typeClassTrait, Class inst return getCompanionObjectInstance(Class.forName(ORDERING + "$Symbol", true, classLoader)); //can't know the orderings for Option, Seq, Either or Tuple, because we would need the ordering instances for the elements, //and we don't know the type arguments sadly. + //TODO is it possible to find out? TypeclassTrait should become a Parameterized(Parameter)Type, right? + //TODO can we make it that? and can we actually provide the type arguments? } break; case CLASSTAG: @@ -204,6 +206,8 @@ public static Object getTypeClassInstance(Class typeClassTrait, Class inst } } } + + // tough luck, nothing to do throw ex; }