From 94be918c363c74f91aa732669a905506d6b04df6 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sun, 17 Jul 2022 19:49:04 +0200 Subject: [PATCH] Add support for native methods with @WasmTextCode in @Partial classes --- src/de/inetsoftware/classparser/ClassFile.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/de/inetsoftware/classparser/ClassFile.java b/src/de/inetsoftware/classparser/ClassFile.java index 22d98a1..253ad31 100644 --- a/src/de/inetsoftware/classparser/ClassFile.java +++ b/src/de/inetsoftware/classparser/ClassFile.java @@ -391,15 +391,19 @@ public class ClassFile { String origClassName = partialClassFile.thisClass.getName(); ArrayList allMethods = new ArrayList<>( Arrays.asList( methods ) ); for( MethodInfo m : partialClassFile.methods ) { - if( m.isNative() && m.getAnnotation( JWebAssembly.IMPORT_ANNOTATION ) == null ) { - // only a placeholder + if( m.isNative() && m.getAnnotation( JWebAssembly.IMPORT_ANNOTATION ) == null && m.getAnnotation( JWebAssembly.TEXTCODE_ANNOTATION ) == null ) { + // only a placeholder, use the original + continue; + } + if( "".equals( m.getName() ) ) { + // can be fatal to override the static constructor continue; } m.setDeclaringClassFile( origClassName, this ); MethodInfo origMethod = getMethod( m.getName(), m.getType() ); if( origMethod == null ) { allMethods.add( m ); - } else if( origMethod.isNative() ) { + } else { allMethods.set( allMethods.indexOf( origMethod ), m ); } }