MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

Check method access when looking for ambiguous method calls #49

Closed JDLogic closed 5 years ago

JDLogic commented 5 years ago

Fixes #48 with both Eclipse J8_OpenJ9 and Oracle J8_Hotspot now producing the same output.

As mentioned in the linked issue, OpenJ9 adds a private System.arraycopy method for jit to reference. This private method made calls to the public method seem ambiguous when they should not be. This was fixed by only matching methods that can be properly accessed.

1.14.2 MC Diff Note: There are two diffs. One is using Eclipse J8_OpenJ9 and the other is using Oracle J8_Hotspot.

bs2609 commented 5 years ago

Looks reasonably like my half-finished attempt at this.

One thing I do see is the access check ordering being different - as protected access is a superset of package access, your code may need to handle package checks also for protected methods.

bs2609 commented 5 years ago

Looking at the diff, the only other real change I can see is the VoxelShapeArray constructor, though I'm curious as to why that method was considered ambiguous - DoubleList doesn't really seem to match double[].

JDLogic commented 5 years ago

Ok, the derp with parameter unboxing is now fixed. I also fixed the protected access check to consider packages as bs2609 mentioned. Diffs have been updated to reflect these changes.

bs2609 commented 5 years ago

New diff looks good.

The JsonPrimitive constructor seems like the only shared change, which is now back to how it was prior to #36 (diff):

diff --git a/before/net/minecraft/world/storage/loot/RandomValueRange.java b/after/net/minecraft/world/storage/loot/RandomValueRange.java
index 7630bb1..a8215ad 100755
--- a/before/net/minecraft/world/storage/loot/RandomValueRange.java
+++ b/after/net/minecraft/world/storage/loot/RandomValueRange.java
@@ -61,7 +61,7 @@ public class RandomValueRange {

       public JsonElement serialize(RandomValueRange p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_) {
          if (p_serialize_1_.field_186514_a == p_serialize_1_.field_186515_b) {
-            return new JsonPrimitive(p_serialize_1_.field_186514_a);
+            return new JsonPrimitive((float)p_serialize_1_.field_186514_a);
          } else {
             JsonObject jsonobject = new JsonObject();
             jsonobject.addProperty("min", p_serialize_1_.field_186514_a);

(note: ConstantRange didn't exist at the time)