Solved Lambda deserialiser??

Discussion in 'Spigot Plugin Development' started by ramidzk, Apr 30, 2017.

?

Who's fault is this?

Poll closed May 7, 2017.
  1. Java's fault

    0 vote(s)
    0.0%
  2. Not my fault

    0 vote(s)
    0.0%
  3. My fault

    2 vote(s)
    100.0%
Thread Status:
Not open for further replies.
  1. I have my little (OK it took me 2 hours to make and 1 hour of JavaDoc writing and 30mins of testing) plugin that serialises some data (like 7 instances of other objects) and writes them out into a file in Base64 (idk anything about how to use base65536). The first test it was fine. Then i decided to replace the inner classes with lambda expressions (I was using java8 all the time its not that). The stack trace showed me that there is a file at io.github.ramidzkh.Maker but there is a serialised file that doesn't need that. When I switched back to the normal way without actual classes (inner classes) it works. Any help?

    The log:
    Code (Text):
    [16:53:43] [Server thread/INFO]: Starting minecraft server version 1.11.2
    [16:53:43] [Server thread/INFO]: Loading properties
    [16:53:43] [Server thread/INFO]: Default game type: SURVIVAL
    [16:53:44] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-d276ab1-d219213 (MC: 1.11.2) (Implementing API version 1.11.2-R0.1-SNAPSHOT)
    [16:53:44] [Server thread/INFO]: Debug logging is disabled
    [16:53:44] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [16:53:44] [Server thread/INFO]: Using 4 threads for Netty based IO
    [16:53:44] [Server thread/INFO]: Generating keypair
    [16:53:44] [Server thread/INFO]: Starting Minecraft server on *:25565
    [16:53:44] [Server thread/INFO]: Using default channel type
    [16:53:45] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [16:53:46] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v6.1.5;4651611
    [16:53:46] [Server thread/INFO]: [Bssentials Reloaded] Loading BssentialsReloaded v1.0.0
    [16:53:46] [Server thread/INFO]: [Plotter] Loading plotter v1.0.0-SNAPSHOT
    [16:53:46] [Server thread/INFO]: [Wolfram|Query] Loading WolframQuery v1.0.0
    [16:53:46] [Server thread/INFO]: [ProtocolLib] Loading ProtocolLib v4.2.1
    [16:53:46] [Server thread/INFO]: [CraftBook] Loading CraftBook v3.9-SNAPSHOT-jenkins-CraftBook-146
    [16:53:46] [Server thread/INFO]: [ProtocolLib] Enabling ProtocolLib v4.2.1
    [16:53:46] [Server thread/INFO]: [ProtocolLib] Started structure compiler thread.
    [16:53:46] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [16:53:46] [Server thread/INFO]: Preparing level "world"
    [16:53:46] [Server thread/INFO]: -------- World Settings For [world] --------
    [16:53:46] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [16:53:46] [Server thread/INFO]: Item Despawn Rate: 6000
    [16:53:46] [Server thread/INFO]: Item Merge Radius: 2.5
    [16:53:46] [Server thread/INFO]: Experience Merge Radius: 3.0
    [16:53:46] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [16:53:46] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [16:53:46] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [16:53:46] [Server thread/INFO]: View Distance: 10
    [16:53:46] [Server thread/INFO]: Mob Spawn Range: 4
    [16:53:46] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [16:53:46] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [16:53:46] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [16:53:46] [Server thread/INFO]: Max TNT Explosions: 100
    [16:53:46] [Server thread/INFO]: Random Lighting Updates: false
    [16:53:46] [Server thread/INFO]: Structure Info Saving: true
    [16:53:46] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Cane Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Melon Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Vine Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [16:53:46] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [16:53:46] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [16:53:47] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [16:53:47] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [16:53:47] [Server thread/INFO]: Item Despawn Rate: 6000
    [16:53:47] [Server thread/INFO]: Item Merge Radius: 2.5
    [16:53:47] [Server thread/INFO]: Experience Merge Radius: 3.0
    [16:53:47] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [16:53:47] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [16:53:47] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [16:53:47] [Server thread/INFO]: View Distance: 10
    [16:53:47] [Server thread/INFO]: Mob Spawn Range: 4
    [16:53:47] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [16:53:47] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [16:53:47] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [16:53:47] [Server thread/INFO]: Max TNT Explosions: 100
    [16:53:47] [Server thread/INFO]: Random Lighting Updates: false
    [16:53:47] [Server thread/INFO]: Structure Info Saving: true
    [16:53:47] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Cane Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Melon Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Vine Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [16:53:47] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [16:53:47] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [16:53:47] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [16:53:47] [Server thread/INFO]: Item Despawn Rate: 6000
    [16:53:47] [Server thread/INFO]: Item Merge Radius: 2.5
    [16:53:47] [Server thread/INFO]: Experience Merge Radius: 3.0
    [16:53:47] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [16:53:47] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [16:53:47] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [16:53:47] [Server thread/INFO]: View Distance: 10
    [16:53:47] [Server thread/INFO]: Mob Spawn Range: 4
    [16:53:47] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [16:53:47] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [16:53:47] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [16:53:47] [Server thread/INFO]: Max TNT Explosions: 100
    [16:53:47] [Server thread/INFO]: Random Lighting Updates: false
    [16:53:47] [Server thread/INFO]: Structure Info Saving: true
    [16:53:47] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Cane Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Melon Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Vine Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [16:53:47] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [16:53:47] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [16:53:47] [Server thread/INFO]: Preparing start region for level 0 (Seed: 9223372036854775807)
    [16:53:47] [Server thread/INFO]: Preparing start region for level 1 (Seed: 9223372036854775807)
    [16:53:48] [Server thread/INFO]: Preparing start region for level 2 (Seed: 9223372036854775807)
    [16:53:48] [Server thread/INFO]: [WorldEdit] Enabling WorldEdit v6.1.5;4651611
    [16:53:49] [Server thread/INFO]: WEPIF: Using the Bukkit Permissions API.
    [16:53:49] [Server thread/INFO]: [WorldEdit] Using com.sk89q.worldedit.bukkit.adapter.impl.Spigot_v1_11_R1 as the Bukkit adapter
    [16:53:49] [Server thread/INFO]: [Bssentials Reloaded] Enabling BssentialsReloaded v1.0.0
    [16:53:49] [Server thread/INFO]: [Plotter] Enabling plotter v1.0.0-SNAPSHOT
    [16:53:49] [Server thread/INFO]: [Plotter] Enabling Plotter
    [16:53:49] [Server thread/ERROR]: [Plotter] Couldn't load plots!
    java.io.IOException: unexpected exception type
        at java.io.ObjectStreamClass.throwMiscException(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectStreamClass.invokeReadResolve(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readObject0(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.defaultReadFields(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readSerialData(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readObject0(Unknown Source) ~[?:1.8.0_121]
        at java.io.ObjectInputStream.readObject(Unknown Source) ~[?:1.8.0_121]
        at io.github.ramidzkh.mc_api.common.Serializer.deserialize(Serializer.java:68) ~[bssentials-1.0.0-jar-with-dependencies.jar:?]
        at io.github.ramidzkh.mc_api.common.Serializer.deserializeBase64(Serializer.java:103) ~[bssentials-1.0.0-jar-with-dependencies.jar:?]
        at io.github.ramidzkh.common.PlotData.deserialize(PlotData.java:150) ~[io.github.ramidzkh.spigot.plotter.1.0.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at io.github.ramidzkh.spigot.plotter.PlotterCore.onEnable(PlotterCore.java:115) [io.github.ramidzkh.spigot.plotter.1.0.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugin(CraftServer.java:376) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugins(CraftServer.java:326) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at net.minecraft.server.v1_11_R1.MinecraftServer.t(MinecraftServer.java:421) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at net.minecraft.server.v1_11_R1.MinecraftServer.l(MinecraftServer.java:382) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at net.minecraft.server.v1_11_R1.MinecraftServer.a(MinecraftServer.java:337) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:544) [spigot-1.11.2.jar:git-Spigot-d276ab1-d219213]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.NoSuchMethodException: io.github.ramidzkh.Maker.$deserializeLambda$(java.lang.invoke.SerializedLambda)
        at java.lang.Class.getDeclaredMethod(Unknown Source) ~[?:1.8.0_121]
        at java.lang.invoke.SerializedLambda$1.run(Unknown Source) ~[?:1.8.0_121]
        at java.lang.invoke.SerializedLambda$1.run(Unknown Source) ~[?:1.8.0_121]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_121]
        at java.lang.invoke.SerializedLambda.readResolve(Unknown Source) ~[?:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121]
        ... 23 more
    [16:53:49] [Server thread/INFO]: [Plotter] Disabling plotter v1.0.0-SNAPSHOT
    [16:53:49] [Server thread/INFO]: [Wolfram|Query] Enabling WolframQuery v1.0.0
    [16:53:49] [Server thread/INFO]: [Wolfram|Query] Your API key is: ######-##########
    [16:53:49] [Server thread/INFO]: [CraftBook] Enabling CraftBook v3.9-SNAPSHOT-jenkins-CraftBook-146
    [16:53:49] [Server thread/INFO]: [CraftBook] Loading persistent data from YAML!
    [16:53:50] [Server thread/INFO]: [CraftBook] Successfully added 1 CommandItems!
    [16:53:50] [Server thread/INFO]: [CraftBook] Registered 3 custom recipes!
    [16:53:51] [Server thread/INFO]: [CraftBook] 1 cauldron recipe(s) loaded
    [16:53:51] [Server thread/INFO]: [CraftBook] Enumerating chunks for self-triggered components...
    [16:53:51] [Server thread/INFO]: [CraftBook] 1875 chunk(s) for 3 world(s) processed (68ms elapsed)
    [16:53:51] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [16:53:51] [Server thread/INFO]: Done (4.265s)! For help, type "help" or "?"

    I wrote stop in the console here

    [17:04:47] [Server thread/INFO]: Stopping the server
    [17:04:47] [Server thread/INFO]: Stopping server
    [17:04:47] [Server thread/INFO]: [CraftBook] Disabling CraftBook v3.9-SNAPSHOT-jenkins-CraftBook-146
    [17:04:47] [Server thread/INFO]: [CraftBook] Saving persistent data to YAML!
    [17:04:47] [Server thread/INFO]: [ProtocolLib] Disabling ProtocolLib v4.2.1
    [17:04:47] [Server thread/INFO]: [Wolfram|Query] Disabling WolframQuery v1.0.0
    [17:04:47] [Server thread/INFO]: [Bssentials Reloaded] Disabling BssentialsReloaded v1.0.0
    [17:04:47] [Server thread/INFO]: [WorldEdit] Disabling WorldEdit v6.1.5;4651611
    [17:04:47] [Server thread/INFO]: Saving players
    [17:04:47] [Server thread/INFO]: Saving worlds
    [17:04:47] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
    [17:04:47] [Server thread/INFO]: Saving chunks for level 'world_nether'/Nether
    [17:04:47] [Server thread/INFO]: Saving chunks for level 'world_the_end'/The End
     

    Line 154 is censored because it's my API key...
     
  2. Use gson to serialize a class?
     
  3. ObjectOutputStream and ByteArrayOutputStream both in java.io
     
  4. I mean, try to use Gson to save classes to string :D
     
  5. No, the way I'm using is very good. It's not that; it's that lambda expressions are stuck on the class i used to make the thing
     
  6. Looks like you are using an external plugin/jar to deserialize, the exception that is thrown is because you are calling an inexisteng method (Reflection? OR justo outdated import)
     
  7. You don't get it.

    The header if your wondering
    Code (Text):
    package io.github.ramidzkh;

    import java.io.File;

    import org.bukkit.Bukkit;
    import org.bukkit.Effect;
    import org.bukkit.Location;
    import org.bukkit.World;

    import io.github.ramidzkh.common.PlotData;
    import io.github.ramidzkh.mc_api.common.Key;
    import io.github.ramidzkh.mc_api.common.TriKey;
    import io.github.ramidzkh.mc_api.common.interfaces.ExtendedRunnable;
    import io.github.ramidzkh.mc_api.common.interfaces.MathFunction;

    public class Maker {
    You make some stuff for X-Y-Z generation
    Code (Text):
           MathFunction<Double, Double> xgen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
       
            MathFunction<Double, Double> ygen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
       
            MathFunction<Double, Double> zgen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
    Then you write some stuff to display the method (Consumer<Key<Double, Double>> doesn't serialise in the first place)
    I'm just returning the given value
    Code (Text):
           MathFunction<Double, Double> xgen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
       
            MathFunction<Double, Double> ygen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
       
            MathFunction<Double, Double> zgen = new MathFunction<Double, Double>() {
                private static final long serialVersionUID = -6288945975559249250L;

                @Override
                public Double doFunction(Double[] arg0) throws Exception {
                    return arg0[0];
                }
            };
    And then I declare the actual thing (Consumer<TriKey<Double, Double, Double>> doesn't serialise in the first place)
    Code (Text):
           ExtendedRunnable<TriKey<Double, Double, Double>> plotter = (i) -> {
                World w = Bukkit.getWorlds().get(1);
                Location l = new Location(w, i.x, i.y, i.z);
                w.playEffect(l, Effect.ENDER_SIGNAL, 0);
            };
       
            PlotData pd = new PlotData(xgen, ygen, zgen, plotter, 15, 15, 15, of(-10, 10), of(-10, 10), of(-10, 10), 0.2);
       
            pd.serialize(new File("plottest.sb64"));
    the method of(double, double) is just this
    Code (Text):
       static Key<Double, Double> of(double a, double b) {
            return new Key<Double, Double>(a, b);
        }
     
    And I put that all in my main method (it works believe me) and I get a new file
    This one.PNG
    And then i put it in my config folder
    And This One.PNG
    And here is the config if your wondering
    And Just This More.PNG
    And then I still get that error.
     
    #7 ramidzk, Apr 30, 2017
    Last edited: May 29, 2017
  8. sothatsit

    Patron

    Your code makes no sense with what you have given us. Why do your math functions have their own serialVersionUIDs? Are you serializing the math functions? That doesn't make sense.
     
  9. I just made those interfaces cause Function<Double, Double> isn't serialisable and Consumer<TriKey<Double, Double, Double>> also isn't so I had no other choice without using something like GSON. Well I fixed it lambda cannot be serialized like how i want it to be like. Guess I'll close this thread.
     
Thread Status:
Not open for further replies.