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

Private implementation detail of `System.arraycopy` in OpenJ9 builds results in casts to parameters being generated for all invocations of method #48

Closed jellysquid3 closed 5 years ago

jellysquid3 commented 5 years ago

When OpenJ9 is used during ForgeGradle's decompile process, additional parameter casts are generated when calling System#arrayCopy(Object, int, Object, int, int) in the produced source code.

For HotSpot builds, the following code may be produced:

System.arraycopy(arr1, 0, arr2, 0, arr2.length);

When using OpenJ9 builds, the following code will instead be generated:

System.arraycopy((Object) arr1, 0, (Object) arr2, 0, arr2.length);

This can lead to issues such as MinecraftForge/ForgeGradle#597, where patches expecting there to be no additional cast fail.

The only difference that can be seen between the OpenJ9 and HotSpot builds for this method is that OpenJ9 includes a private reference implementation alongside it. I suspect this is the reason the cast is produced, as two methods exist with different parameter types.

bs2609 commented 5 years ago

Likely also the cause of https://github.com/MinecraftForge/ForgeGradle/issues/595.