mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-04 14:14:11 -08:00
Fix first-time instantiation via reflection.
In 7fc035f
, a general fix to instantiation via reflection was made and a
test case added. The test case fails due to a separate issue, solved in
this commit, which affects only the first instantiation via reflection.
This commit is contained in:
parent
7fc035fd8a
commit
3d0dee98be
platform/src/main/java/org/teavm/platform
|
@ -33,6 +33,8 @@ public final class Platform {
|
|||
private Platform() {
|
||||
}
|
||||
|
||||
private static boolean newInstancePrepared;
|
||||
|
||||
@InjectedBy(PlatformGenerator.class)
|
||||
public static native PlatformObject getPlatformObject(Object obj);
|
||||
|
||||
|
@ -85,7 +87,10 @@ public final class Platform {
|
|||
public static native int nextObjectId();
|
||||
|
||||
public static <T> T newInstance(PlatformClass cls) {
|
||||
prepareNewInstance();
|
||||
if (!newInstancePrepared) {
|
||||
prepareNewInstance();
|
||||
newInstancePrepared = true;
|
||||
}
|
||||
return newInstanceImpl(cls);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,6 @@ public class PlatformGenerator implements Generator, Injector, DependencyPlugin
|
|||
.appendMethodBody(method.getReference()).append(";").softNewLine();
|
||||
}
|
||||
}
|
||||
writer.appendMethodBody(Platform.class, "newInstance", PlatformClass.class, Object.class).ws().append('=').ws()
|
||||
.appendMethodBody(Platform.class, "newInstanceImpl", PlatformClass.class, Object.class)
|
||||
.append(";").softNewLine();
|
||||
}
|
||||
|
||||
private void generateNewInstance(GeneratorContext context, SourceWriter writer) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue
Block a user