dev-develop
dev-developKarsk - java bytecode writer
MIT
The Requires
- php >=7.1
The Development Requires
- phpunit/phpunit ^7.1
- mikey179/vfsstream ~1
- squizlabs/php_codesniffer 3.*
- phpdocumentor/phpdocumentor 2.*
by Bohuslav Simek
Karsk - java bytecode writer
Karsk is direct port of ASM "a very small and fast Java bytecode manipulation framework"., (*2)
This is highly experimental and very much work in progress at this moment. Any help is welcome!, (*3)
Preferred way to install framework is with composer:, (*4)
composer require kambo/karsk
public class Helloworld { public static void main (String[] args) { System.out.println("Hello world!"); } }
<?php use Kambo\Karsk\ClassWriter; use Kambo\Karsk\Opcodes; $cw = new ClassWriter(0); $cw->visit( Opcodes::V1_8, Opcodes::ACC_PUBLIC, "Helloworld", null, "java/lang/Object", null ); $mw = $cw->visitMethod(Opcodes::ACC_PUBLIC, "<init>", "()V", null, null); $mw->visitVarInsn(Opcodes::ALOAD, 0); $mw->visitMethodInsn(Opcodes::INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); $mw->visitInsn(Opcodes::RETURN_); $mw->visitMaxs(1, 1); $mw->visitEnd(); $mainMethod = $cw->visitMethod( (Opcodes::ACC_PUBLIC + Opcodes::ACC_STATIC), "main", "([Ljava/lang/String;)V", null, null ); $mainMethod->visitFieldInsn(Opcodes::GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); $mainMethod->visitLdcInsn("Hello world!"); $mainMethod->visitMethodInsn( Opcodes::INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false ); $mainMethod->visitInsn(Opcodes::RETURN_); $mainMethod->visitMaxs(2, 2); $mainMethod->visitEnd(); $code = $cw->toByteArray();
3-Clause BSD, https://opensource.org/licenses/BSD-3-Clause, (*5)
Karsk - java bytecode writer
MIT