pax_global_header00006660000000000000000000000064140515610360014513gustar00rootroot0000000000000052 comment=2b5b897f01f215fcd1fad51df4a5a749cf65cdd8 jitescript-jitescript-0.4.3/000077500000000000000000000000001405156103600160555ustar00rootroot00000000000000jitescript-jitescript-0.4.3/.gitignore000066400000000000000000000001161405156103600200430ustar00rootroot00000000000000.gradle build .*.swp *.iml *.ipr *.iws /target/ /nb-configuration.xml /.idea/ jitescript-jitescript-0.4.3/.travis.yml000066400000000000000000000001671405156103600201720ustar00rootroot00000000000000language: java matrix: include: - arch: amd64 - arch: ppc64le addons: [ apt: [ packages: maven ]] jitescript-jitescript-0.4.3/LICENSE000066400000000000000000000236771405156103600171010ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS jitescript-jitescript-0.4.3/README.md000066400000000000000000000015511405156103600173360ustar00rootroot00000000000000Jitescript - Java API for Bytecode ================================== This project is inspired by @headius's [BiteScript](https://github.com/headius/bitescript). The goal is to produce a Java library with a similar API so that bytecode generation can be as nice in Java as BiteScript makes it in JRuby. ![cloudbees rocks!](http://static-www.cloudbees.com/images/badges/BuiltOnDEV.png) Quickstart ================================== Just add the project maven dependency info: me.qmx.jitescript jitescript 0.3.0 Then take a look at [JiteClassTest](https://github.com/qmx/jitescript/blob/master/src/test/java/me/qmx/jitescript/JiteClassTest.java) example on how to use it. How to get help =============== Join us on `#dynjs` channel at irc.freenode.net.jitescript-jitescript-0.4.3/pom.xml000066400000000000000000000141731405156103600174000ustar00rootroot00000000000000 4.0.0 me.qmx.jitescript jitescript 0.4.3 jar jitescript Java API for Bytecode https://github.com/qmx/jitescript UTF-8 org.sonatype.oss oss-parent 7 The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt repo scm:git:git@github.com:qmx/jitescript.git scm:git:git@github.com:qmx/jitescript.git git@github.com:qmx/jitescript.git jitescript-0.4.3 qmx Douglas Campos http://github.com/qmx qmx@qmx.me Software Developer org.ow2.asm asm-all 5.0.1 compile junit junit 4.13.1 test org.easytesting fest-assert 1.4 test org.apache.maven.wagon wagon-webdav-jackrabbit 1.0-beta-7 org.apache.maven.plugins maven-compiler-plugin 2.3.2 7 7 ${project.build.sourceEncoding} org.apache.maven.plugins maven-jar-plugin 3.2.0 me.qmx.jitescript org.apache.maven.plugins maven-release-plugin 2.4 false org.apache.maven.plugins maven-source-plugin 2.1.2 attach-sources verify jar-no-fork org.apache.maven.plugins maven-resources-plugin 2.4.2 ${project.build.sourceEncoding} com.mycila.maven-license-plugin maven-license-plugin 1.9.0
src/etc/header.txt
src/** true
release-sign-artifacts performRelease true org.apache.maven.plugins maven-gpg-plugin 1.4 sign-artifacts verify sign
jitescript-jitescript-0.4.3/src/000077500000000000000000000000001405156103600166445ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/etc/000077500000000000000000000000001405156103600174175ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/etc/header.txt000066400000000000000000000011011405156103600214010ustar00rootroot00000000000000 Copyright ${year} Douglas Campos Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. jitescript-jitescript-0.4.3/src/main/000077500000000000000000000000001405156103600175705ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/000077500000000000000000000000001405156103600205115ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/me/000077500000000000000000000000001405156103600211125ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/me/qmx/000077500000000000000000000000001405156103600217175ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/000077500000000000000000000000001405156103600240775ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/AnnotationArrayValue.java000066400000000000000000000006071405156103600310530ustar00rootroot00000000000000package me.qmx.jitescript; import org.objectweb.asm.AnnotationVisitor; public class AnnotationArrayValue { private final String name; private final AnnotationVisitor node; public AnnotationArrayValue(String name, AnnotationVisitor node) { this.name = name; this.node = node; } public void add(Object value) { node.visit(name, value); } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/CodeBlock.java000066400000000000000000000776071405156103600266100ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.FieldInsnNode; import org.objectweb.asm.tree.FrameNode; import org.objectweb.asm.tree.IincInsnNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.InsnNode; import org.objectweb.asm.tree.IntInsnNode; import org.objectweb.asm.tree.InvokeDynamicInsnNode; import org.objectweb.asm.tree.JumpInsnNode; import org.objectweb.asm.tree.LabelNode; import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.LineNumberNode; import org.objectweb.asm.tree.LocalVariableNode; import org.objectweb.asm.tree.LookupSwitchInsnNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MultiANewArrayInsnNode; import org.objectweb.asm.tree.TableSwitchInsnNode; import org.objectweb.asm.tree.TryCatchBlockNode; import org.objectweb.asm.tree.TypeInsnNode; import org.objectweb.asm.tree.VarInsnNode; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; import static me.qmx.jitescript.util.CodegenUtils.ci; import static me.qmx.jitescript.util.CodegenUtils.p; import static me.qmx.jitescript.util.CodegenUtils.params; import static me.qmx.jitescript.util.CodegenUtils.sig; /** * @author qmx */ public class CodeBlock implements Opcodes { private final InsnList instructionList = new InsnList(); private final List tryCatchBlockList = new ArrayList(); private final List localVariableList = new ArrayList(); private final List annotations = new ArrayList(); private int arity = 0; private boolean returns = false; public CodeBlock() { } public CodeBlock(final CodeBlock block) { arity = block.arity(); prepend(block); } public CodeBlock(final int arity) { this.arity = arity; } public static CodeBlock newCodeBlock() { return new CodeBlock(); } public static CodeBlock newCodeBlock(final int arity) { return new CodeBlock(arity); } public static CodeBlock newCodeBlock(final CodeBlock block) { return new CodeBlock(block); } /** * Short-hand for specifying a set of aloads * * @param indices list of aloads you want */ public CodeBlock aloadMany(final int... indices) { for (final int index : indices) aload(index); return this; } public CodeBlock aload(final int index) { instructionList.add(new VarInsnNode(ALOAD, index)); return this; } public CodeBlock iload(final int index) { instructionList.add(new VarInsnNode(ILOAD, index)); return this; } public CodeBlock lload(final int index) { instructionList.add(new VarInsnNode(LLOAD, index)); return this; } public CodeBlock fload(final int index) { instructionList.add(new VarInsnNode(FLOAD, index)); return this; } public CodeBlock dload(final int index) { instructionList.add(new VarInsnNode(DLOAD, index)); return this; } public CodeBlock astore(final int index) { instructionList.add(new VarInsnNode(ASTORE, index)); return this; } public CodeBlock istore(final int index) { instructionList.add(new VarInsnNode(ISTORE, index)); return this; } public CodeBlock lstore(final int index) { instructionList.add(new VarInsnNode(LSTORE, index)); return this; } public CodeBlock fstore(final int index) { instructionList.add(new VarInsnNode(FSTORE, index)); return this; } public CodeBlock dstore(final int index) { instructionList.add(new VarInsnNode(DSTORE, index)); return this; } public CodeBlock ldc(final Object value) { instructionList.add(new LdcInsnNode(value)); return this; } public CodeBlock bipush(final int byteValue) { instructionList.add(new IntInsnNode(BIPUSH, byteValue)); return this; } public CodeBlock sipush(final int shortValue) { instructionList.add(new IntInsnNode(SIPUSH, shortValue)); return this; } public CodeBlock pushInt(final int value) { if (value <= Byte.MAX_VALUE && value >= Byte.MIN_VALUE) { switch (value) { case -1: iconst_m1(); break; case 0: iconst_0(); break; case 1: iconst_1(); break; case 2: iconst_2(); break; case 3: iconst_3(); break; case 4: iconst_4(); break; case 5: iconst_5(); break; default: bipush(value); break; } } else if (value <= Short.MAX_VALUE && value >= Short.MIN_VALUE) { sipush(value); } else { ldc(value); } return this; } public CodeBlock pushBoolean(final boolean bool) { if (bool) iconst_1(); else iconst_0(); return this; } public CodeBlock invokestatic(final String className, final String methodName, final String methodDesc) { instructionList.add(new MethodInsnNode(INVOKESTATIC, className, methodName, methodDesc, false)); return this; } public CodeBlock invokespecial(final String className, final String methodName, final String methodDesc) { instructionList.add(new MethodInsnNode(INVOKESPECIAL, className, methodName, methodDesc, false)); return this; } public CodeBlock invokevirtual(final String className, final String methodName, final String methodDesc) { instructionList.add(new MethodInsnNode(INVOKEVIRTUAL, className, methodName, methodDesc, false)); return this; } public CodeBlock invokeinterface(final String className, final String methodName, final String methodDesc) { instructionList.add(new MethodInsnNode(INVOKEINTERFACE, className, methodName, methodDesc, true)); return this; } public CodeBlock invokedynamic(final String name, final String descriptor, final Handle bootstrapMethod, final Object... bootstrapArguments) { instructionList.add(new InvokeDynamicInsnNode(name, descriptor, bootstrapMethod, bootstrapArguments)); return this; } public CodeBlock aprintln() { dup(); getstatic(p(System.class), "out", ci(PrintStream.class)); swap(); invokevirtual(p(PrintStream.class), "println", sig(void.class, params(Object.class))); return this; } public CodeBlock iprintln() { dup(); getstatic(p(System.class), "out", ci(PrintStream.class)); swap(); invokevirtual(p(PrintStream.class), "println", sig(void.class, params(int.class))); return this; } public CodeBlock areturn() { returns = true; instructionList.add(new InsnNode(ARETURN)); return this; } public CodeBlock ireturn() { instructionList.add(new InsnNode(IRETURN)); return this; } public CodeBlock freturn() { instructionList.add(new InsnNode(FRETURN)); return this; } public CodeBlock lreturn() { instructionList.add(new InsnNode(LRETURN)); return this; } public CodeBlock dreturn() { instructionList.add(new InsnNode(DRETURN)); return this; } public CodeBlock newobj(final String desc) { instructionList.add(new TypeInsnNode(NEW, desc)); return this; } public CodeBlock dup() { instructionList.add(new InsnNode(DUP)); return this; } public CodeBlock swap() { instructionList.add(new InsnNode(SWAP)); return this; } public CodeBlock swap2() { dup2_x2(); pop2(); return this; } public CodeBlock getstatic(final String className, final String fieldName, final String fieldDesc) { instructionList.add(new FieldInsnNode(GETSTATIC, className, fieldName, fieldDesc)); return this; } public CodeBlock putstatic(final String className, final String fieldName, final String fieldDesc) { instructionList.add(new FieldInsnNode(PUTSTATIC, className, fieldName, fieldDesc)); return this; } public CodeBlock getfield(final String className, final String fieldName, final String fieldDesc) { instructionList.add(new FieldInsnNode(GETFIELD, className, fieldName, fieldDesc)); return this; } public CodeBlock putfield(final String className, final String fieldName, final String fieldDesc) { instructionList.add(new FieldInsnNode(PUTFIELD, className, fieldName, fieldDesc)); return this; } public CodeBlock voidreturn() { instructionList.add(new InsnNode(RETURN)); return this; } public CodeBlock anewarray(final String arrayDesc) { instructionList.add(new TypeInsnNode(ANEWARRAY, arrayDesc)); return this; } public CodeBlock multianewarray(final String arrayDesc, final int dims) { instructionList.add(new MultiANewArrayInsnNode(arrayDesc, dims)); return this; } public CodeBlock newarray(final int size) { instructionList.add(new IntInsnNode(NEWARRAY, size)); return this; } public CodeBlock iconst_m1() { instructionList.add(new InsnNode(Opcodes.ICONST_M1)); return this; } public CodeBlock iconst_0() { instructionList.add(new InsnNode(Opcodes.ICONST_0)); return this; } public CodeBlock iconst_1() { instructionList.add(new InsnNode(Opcodes.ICONST_1)); return this; } public CodeBlock iconst_2() { instructionList.add(new InsnNode(Opcodes.ICONST_2)); return this; } public CodeBlock iconst_3() { instructionList.add(new InsnNode(Opcodes.ICONST_3)); return this; } public CodeBlock iconst_4() { instructionList.add(new InsnNode(Opcodes.ICONST_4)); return this; } public CodeBlock iconst_5() { instructionList.add(new InsnNode(Opcodes.ICONST_5)); return this; } public CodeBlock lconst_0() { instructionList.add(new InsnNode(Opcodes.LCONST_0)); return this; } public CodeBlock aconst_null() { instructionList.add(new InsnNode(Opcodes.ACONST_NULL)); return this; } public CodeBlock label(final LabelNode labelNode) { instructionList.add(labelNode); return this; } public CodeBlock nop() { instructionList.add(new InsnNode(Opcodes.NOP)); return this; } public CodeBlock pop() { instructionList.add(new InsnNode(POP)); return this; } public CodeBlock pop2() { instructionList.add(new InsnNode(POP2)); return this; } public CodeBlock arrayload() { instructionList.add(new InsnNode(AALOAD)); return this; } public CodeBlock arraystore() { instructionList.add(new InsnNode(AASTORE)); return this; } public CodeBlock iarrayload() { instructionList.add(new InsnNode(IALOAD)); return this; } public CodeBlock barrayload() { instructionList.add(new InsnNode(BALOAD)); return this; } public CodeBlock barraystore() { instructionList.add(new InsnNode(BASTORE)); return this; } public CodeBlock aaload() { instructionList.add(new InsnNode(AALOAD)); return this; } public CodeBlock aastore() { instructionList.add(new InsnNode(AASTORE)); return this; } public CodeBlock iaload() { instructionList.add(new InsnNode(IALOAD)); return this; } public CodeBlock iastore() { instructionList.add(new InsnNode(IASTORE)); return this; } public CodeBlock laload() { instructionList.add(new InsnNode(LALOAD)); return this; } public CodeBlock lastore() { instructionList.add(new InsnNode(LASTORE)); return this; } public CodeBlock baload() { instructionList.add(new InsnNode(BALOAD)); return this; } public CodeBlock bastore() { instructionList.add(new InsnNode(BASTORE)); return this; } public CodeBlock saload() { instructionList.add(new InsnNode(SALOAD)); return this; } public CodeBlock sastore() { instructionList.add(new InsnNode(SASTORE)); return this; } public CodeBlock caload() { instructionList.add(new InsnNode(CALOAD)); return this; } public CodeBlock castore() { instructionList.add(new InsnNode(CASTORE)); return this; } public CodeBlock faload() { instructionList.add(new InsnNode(FALOAD)); return this; } public CodeBlock fastore() { instructionList.add(new InsnNode(FASTORE)); return this; } public CodeBlock daload() { instructionList.add(new InsnNode(DALOAD)); return this; } public CodeBlock dastore() { instructionList.add(new InsnNode(DASTORE)); return this; } public CodeBlock fcmpl() { instructionList.add(new InsnNode(FCMPL)); return this; } public CodeBlock fcmpg() { instructionList.add(new InsnNode(FCMPG)); return this; } public CodeBlock dcmpl() { instructionList.add(new InsnNode(DCMPL)); return this; } public CodeBlock dcmpg() { instructionList.add(new InsnNode(DCMPG)); return this; } public CodeBlock dup_x2() { instructionList.add(new InsnNode(DUP_X2)); return this; } public CodeBlock dup_x1() { instructionList.add(new InsnNode(DUP_X1)); return this; } public CodeBlock dup2_x2() { instructionList.add(new InsnNode(DUP2_X2)); return this; } public CodeBlock dup2_x1() { instructionList.add(new InsnNode(DUP2_X1)); return this; } public CodeBlock dup2() { instructionList.add(new InsnNode(DUP2)); return this; } public CodeBlock trycatch(final LabelNode scopeStart, final LabelNode scopeEnd, final LabelNode handler, final String exceptionType) { tryCatchBlockList.add(new TryCatchBlockNode(scopeStart, scopeEnd, handler, exceptionType)); return this; } public CodeBlock trycatch(final String exceptionType, final Runnable body, final Runnable catchBody) { final LabelNode before = new LabelNode(); final LabelNode after = new LabelNode(); final LabelNode catchStart = new LabelNode(); final LabelNode done = new LabelNode(); trycatch(before, after, catchStart, exceptionType); label(before); body.run(); label(after); go_to(done); if (catchBody != null) { label(catchStart); catchBody.run(); } label(done); return this; } public CodeBlock go_to(final LabelNode label) { instructionList.add(new JumpInsnNode(GOTO, label)); return this; } public CodeBlock lookupswitch(final LabelNode defaultHandler, final int[] keys, final LabelNode[] handlers) { instructionList.add(new LookupSwitchInsnNode(defaultHandler, keys, handlers)); return this; } public CodeBlock athrow() { instructionList.add(new InsnNode(ATHROW)); return this; } public CodeBlock instance_of(final String typeDesc) { instructionList.add(new TypeInsnNode(INSTANCEOF, typeDesc)); return this; } public CodeBlock ifeq(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFEQ, jumpLabel)); return this; } public CodeBlock iffalse(final LabelNode jumpLabel) { ifeq(jumpLabel); return this; } public CodeBlock ifne(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFNE, jumpLabel)); return this; } public CodeBlock iftrue(final LabelNode jumpLabel) { ifne(jumpLabel); return this; } public CodeBlock if_acmpne(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ACMPNE, jumpLabel)); return this; } public CodeBlock if_acmpeq(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ACMPEQ, jumpLabel)); return this; } public CodeBlock if_icmple(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPLE, jumpLabel)); return this; } public CodeBlock if_icmpgt(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPGT, jumpLabel)); return this; } public CodeBlock if_icmplt(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPLT, jumpLabel)); return this; } public CodeBlock if_icmpne(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPNE, jumpLabel)); return this; } public CodeBlock if_icmpeq(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPEQ, jumpLabel)); return this; } public CodeBlock if_icmpge(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IF_ICMPGE, jumpLabel)); return this; } public CodeBlock checkcast(final String typeDesc) { instructionList.add(new TypeInsnNode(CHECKCAST, typeDesc)); return this; } public CodeBlock line(final int line) { visitLineNumber(line, new LabelNode()); return this; } public CodeBlock line(final int line, final LabelNode label) { visitLineNumber(line, label); return this; } public CodeBlock ifnonnull(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFNONNULL, jumpLabel)); return this; } public CodeBlock ifnull(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFNULL, jumpLabel)); return this; } public CodeBlock iflt(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFLT, jumpLabel)); return this; } public CodeBlock ifle(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFLE, jumpLabel)); return this; } public CodeBlock ifgt(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFGT, jumpLabel)); return this; } public CodeBlock ifge(final LabelNode jumpLabel) { instructionList.add(new JumpInsnNode(IFGE, jumpLabel)); return this; } public CodeBlock arraylength() { instructionList.add(new InsnNode(ARRAYLENGTH)); return this; } public CodeBlock ishr() { instructionList.add(new InsnNode(ISHR)); return this; } public CodeBlock ishl() { instructionList.add(new InsnNode(ISHL)); return this; } public CodeBlock iushr() { instructionList.add(new InsnNode(IUSHR)); return this; } public CodeBlock lshr() { instructionList.add(new InsnNode(LSHR)); return this; } public CodeBlock lshl() { instructionList.add(new InsnNode(LSHL)); return this; } public CodeBlock lushr() { instructionList.add(new InsnNode(LUSHR)); return this; } public CodeBlock lcmp() { instructionList.add(new InsnNode(LCMP)); return this; } public CodeBlock iand() { instructionList.add(new InsnNode(IAND)); return this; } public CodeBlock ior() { instructionList.add(new InsnNode(IOR)); return this; } public CodeBlock ixor() { instructionList.add(new InsnNode(IXOR)); return this; } public CodeBlock land() { instructionList.add(new InsnNode(LAND)); return this; } public CodeBlock lor() { instructionList.add(new InsnNode(LOR)); return this; } public CodeBlock lxor() { instructionList.add(new InsnNode(LXOR)); return this; } public CodeBlock iadd() { instructionList.add(new InsnNode(IADD)); return this; } public CodeBlock ladd() { instructionList.add(new InsnNode(LADD)); return this; } public CodeBlock fadd() { instructionList.add(new InsnNode(FADD)); return this; } public CodeBlock dadd() { instructionList.add(new InsnNode(DADD)); return this; } public CodeBlock isub() { instructionList.add(new InsnNode(ISUB)); return this; } public CodeBlock lsub() { instructionList.add(new InsnNode(LSUB)); return this; } public CodeBlock fsub() { instructionList.add(new InsnNode(FSUB)); return this; } public CodeBlock dsub() { instructionList.add(new InsnNode(DSUB)); return this; } public CodeBlock idiv() { instructionList.add(new InsnNode(IDIV)); return this; } public CodeBlock irem() { instructionList.add(new InsnNode(IREM)); return this; } public CodeBlock ineg() { instructionList.add(new InsnNode(INEG)); return this; } public CodeBlock i2d() { instructionList.add(new InsnNode(I2D)); return this; } public CodeBlock i2l() { instructionList.add(new InsnNode(I2L)); return this; } public CodeBlock i2f() { instructionList.add(new InsnNode(I2F)); return this; } public CodeBlock i2s() { instructionList.add(new InsnNode(I2S)); return this; } public CodeBlock i2c() { instructionList.add(new InsnNode(I2C)); return this; } public CodeBlock i2b() { instructionList.add(new InsnNode(I2B)); return this; } public CodeBlock ldiv() { instructionList.add(new InsnNode(LDIV)); return this; } public CodeBlock lrem() { instructionList.add(new InsnNode(LREM)); return this; } public CodeBlock lneg() { instructionList.add(new InsnNode(LNEG)); return this; } public CodeBlock l2d() { instructionList.add(new InsnNode(L2D)); return this; } public CodeBlock l2i() { instructionList.add(new InsnNode(L2I)); return this; } public CodeBlock l2f() { instructionList.add(new InsnNode(L2F)); return this; } public CodeBlock fdiv() { instructionList.add(new InsnNode(FDIV)); return this; } public CodeBlock frem() { instructionList.add(new InsnNode(FREM)); return this; } public CodeBlock fneg() { instructionList.add(new InsnNode(FNEG)); return this; } public CodeBlock f2d() { instructionList.add(new InsnNode(F2D)); return this; } public CodeBlock f2i() { instructionList.add(new InsnNode(F2D)); return this; } public CodeBlock f2l() { instructionList.add(new InsnNode(F2L)); return this; } public CodeBlock ddiv() { instructionList.add(new InsnNode(DDIV)); return this; } public CodeBlock drem() { instructionList.add(new InsnNode(DREM)); return this; } public CodeBlock dneg() { instructionList.add(new InsnNode(DNEG)); return this; } public CodeBlock d2f() { instructionList.add(new InsnNode(D2F)); return this; } public CodeBlock d2i() { instructionList.add(new InsnNode(D2I)); return this; } public CodeBlock d2l() { instructionList.add(new InsnNode(D2L)); return this; } public CodeBlock imul() { instructionList.add(new InsnNode(IMUL)); return this; } public CodeBlock lmul() { instructionList.add(new InsnNode(LMUL)); return this; } public CodeBlock fmul() { instructionList.add(new InsnNode(FMUL)); return this; } public CodeBlock dmul() { instructionList.add(new InsnNode(DMUL)); return this; } public CodeBlock iinc(final int varIndex, final int increment) { instructionList.add(new IincInsnNode(varIndex, increment)); return this; } public CodeBlock monitorenter() { instructionList.add(new InsnNode(MONITORENTER)); return this; } public CodeBlock monitorexit() { instructionList.add(new InsnNode(MONITOREXIT)); return this; } public CodeBlock jsr(final LabelNode branch) { instructionList.add(new JumpInsnNode(JSR, branch)); return this; } public CodeBlock ret(final int value) { instructionList.add(new IntInsnNode(RET, value)); return this; } public CodeBlock visitInsn(final int opcode) { instructionList.add(new InsnNode(opcode)); return this; } public CodeBlock visitIntInsn(final int opcode, final int operand) { instructionList.add(new IntInsnNode(opcode, operand)); return this; } public CodeBlock visitInsnNode(final int opcode, final int operand) { instructionList.add(new IntInsnNode(opcode, operand)); return this; } public CodeBlock visitTypeInsn(final int opcode, final String desc) { instructionList.add(new TypeInsnNode(opcode, desc)); return this; } public CodeBlock visitFieldInsn(final int opcode, final String className, final String fieldName, final String fieldDesc) { instructionList.add(new FieldInsnNode(opcode, className, fieldName, fieldDesc)); return this; } public CodeBlock visitMethodInsn(final int opcode, final String className, final String methodName, final String methodDesc) { final boolean intf = opcode == INVOKEINTERFACE; instructionList.add(new MethodInsnNode(opcode, className, methodName, methodDesc, intf)); return this; } public CodeBlock visitInvokeDynamicInsn(final String name, final String desc, final Handle bootstrapMethod, final Object... bootstrapArguments) { instructionList.add(new InvokeDynamicInsnNode(name, desc, bootstrapMethod, bootstrapArguments)); return this; } public CodeBlock visitJumpInsn(final int opcode, final LabelNode node) { instructionList.add(new JumpInsnNode(opcode, node)); return this; } public CodeBlock visitLabel(final Label label) { instructionList.add(new LabelNode(label)); return this; } public CodeBlock visitLdcInsn(final Object value) { instructionList.add(new LdcInsnNode(value)); return this; } public CodeBlock visitIincInsn(final int varIndex, final int increment) { instructionList.add(new IincInsnNode(varIndex, increment)); return this; } public CodeBlock visitTableSwitchInsn(final int min, final int max, final LabelNode defaultHandler, final LabelNode[] handlers) { instructionList.add(new TableSwitchInsnNode(min, max, defaultHandler, handlers)); return this; } public CodeBlock visitLookupSwitchInsn(final LabelNode defaultHandler, final int[] keys, final LabelNode[] handlers) { instructionList.add(new LookupSwitchInsnNode(defaultHandler, keys, handlers)); return this; } public CodeBlock visitMultiANewArrayInsn(final String desc, final int dims) { instructionList.add(new MultiANewArrayInsnNode(desc, dims)); return this; } public CodeBlock visitTryCatchBlock(final LabelNode scopeStart, final LabelNode scopeEnd, final LabelNode handler, final String exceptionType) { tryCatchBlockList.add(new TryCatchBlockNode(scopeStart, scopeEnd, handler, exceptionType)); return this; } public CodeBlock visitLocalVariable(final String varName, final String varDesc, final String signature, final LabelNode scopeStart, final LabelNode scopeEnd, final int varIndex) { localVariableList.add(new LocalVariableNode(varName, varDesc, signature, scopeStart, scopeEnd, varIndex)); return this; } public CodeBlock visitLineNumber(final int lineNumber, final LabelNode start) { instructionList.add(new LineNumberNode(lineNumber, start)); return this; } public CodeBlock tableswitch(final int min, final int max, final LabelNode defaultLabel, final LabelNode[] cases) { instructionList.add(new TableSwitchInsnNode(min, max, defaultLabel, cases)); return this; } public CodeBlock visitFrame(final int opcode, final int nrLocals, final Object[] localTypes, final int nrStackElements, final Object[] stackElements) { instructionList.add(new FrameNode(opcode, nrLocals, localTypes, nrStackElements, stackElements)); return this; } public InsnList getInstructionList() { return instructionList; } public List getTryCatchBlockList() { return tryCatchBlockList; } public List getLocalVariableList() { return localVariableList; } public List getAnnotations() { return annotations; } /** * adds a compressed frame to the stack * * @param stackArguments the argument types on the stack, represented as * "class path names" e.g java/lang/RuntimeException */ public CodeBlock frame_same(final Object... stackArguments) { final int type; switch (stackArguments.length) { case 0: type = Opcodes.F_SAME; break; case 1: type = Opcodes.F_SAME1; break; default: throw new IllegalArgumentException("same frame should have 0" + " or 1 arguments on stack"); } instructionList.add(new FrameNode(type, 0, null, stackArguments.length, stackArguments)); return this; } public CodeBlock prepend(final CodeBlock codeBlock) { if (codeBlock.returns()) returns = true; annotations.addAll(codeBlock.annotations); instructionList.insert(codeBlock.instructionList); return this; } public CodeBlock append(final CodeBlock codeBlock) { if (codeBlock.returns()) returns = true; instructionList.add(codeBlock.instructionList); tryCatchBlockList.addAll(codeBlock.tryCatchBlockList); annotations.addAll(codeBlock.annotations); return this; } public VisibleAnnotation annotation(final Class type) { final VisibleAnnotation annotation = new VisibleAnnotation(ci(type)); addAnnotation(annotation); return annotation; } public CodeBlock addAnnotation(final VisibleAnnotation annotation) { annotations.add(annotation); return this; } public CodeBlock addAll(final InsnList insnList) { instructionList.add(insnList); return this; } public int arity() { return arity; } public boolean returns() { return returns; } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/FieldDefinition.java000066400000000000000000000022361405156103600300010ustar00rootroot00000000000000package me.qmx.jitescript; import java.util.ArrayList; import java.util.List; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.FieldNode; public class FieldDefinition { private final String fieldName; private final int modifiers; private final String signature; private final Object value; private final List annotations; public FieldDefinition(String fieldName, int modifiers, String signature, Object value) { this.fieldName = fieldName; this.modifiers = modifiers; this.signature = signature; this.value = value; this.annotations = new ArrayList(); } public FieldNode getFieldNode() { FieldNode node = new FieldNode(modifiers, fieldName, signature, null, value); node.visibleAnnotations = new ArrayList(); for (VisibleAnnotation annotation : annotations) { node.visibleAnnotations.add(annotation.getNode()); } return node; } public FieldDefinition addAnnotation(VisibleAnnotation annotation) { annotations.add(annotation); return this; } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/JDKVersion.java000066400000000000000000000016511405156103600267230ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript; import org.objectweb.asm.Opcodes; public enum JDKVersion implements Opcodes { V1_6(Opcodes.V1_6), V1_7(Opcodes.V1_7), V1_8(Opcodes.V1_8); private final int ver; JDKVersion(int ver) { this.ver = ver; } public int getVer() { return ver; } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/JiteClass.java000066400000000000000000000202751405156103600266310ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript; import static me.qmx.jitescript.CodeBlock.newCodeBlock; import static me.qmx.jitescript.util.CodegenUtils.p; import static me.qmx.jitescript.util.CodegenUtils.sig; import java.util.ArrayList; import java.util.List; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; /** * Represents a Java Class * * @author qmx */ public class JiteClass implements Opcodes { public static final String[] INTERFACES = new String[]{}; private final List methods = new ArrayList(); private final List fields = new ArrayList(); private final List interfaces = new ArrayList(); private final List annotations = new ArrayList(); private final List childClasses = new ArrayList(); private final String className; private final String superClassName; private String sourceFile; private String sourceDebug; private int access = ACC_PUBLIC; private String parentClassName; /** * Creates a new class representation * * @param className the desired class name */ public JiteClass(String className) { this(className, INTERFACES); } /** * Creates a new class representation * * @param className the desired class name * @param interfaces the desired java interfaces this class will implement */ public JiteClass(String className, String[] interfaces) { this(className, p((Class) Object.class), interfaces); } /** * Creates a new class representation * * @param className the desired class name * @param superClassName the desired parent class * @param interfaces the desired java interfaces this class will implement */ public JiteClass(String className, String superClassName, String[] interfaces) { this.className = className; this.superClassName = superClassName; for (String anInterface : interfaces) { this.interfaces.add(anInterface); } } public int getAccess() { return access; } public String getClassName() { return className; } public String getParentClassName() { return parentClassName; } public void setAccess(int access) { this.access = access; } public void setParentClassName(String parentClassName) { this.parentClassName = parentClassName; } public void setSourceFile(String sourceFile) { this.sourceFile = sourceFile; } public void setSourceDebug(String sourceDebug) { this.sourceDebug = sourceDebug; } public void addChildClass(JiteClass child) { String childName = child.getClassName(); if (childName.contains("$")) { childName = childName.substring(childName.lastIndexOf('$') + 1); } else { childName = childName.substring(childName.lastIndexOf('/') + 1); } addChildClass(childName.substring(childName.lastIndexOf('$') + 1), child); } public void addChildClass(String innerName, JiteClass child) { child.setParentClassName(getClassName()); childClasses.add(new ChildEntry(innerName, child)); } public List getChildClasses() { List childClasses = new ArrayList(); for (ChildEntry child : this.childClasses) { childClasses.add(child.getJiteClass()); } return childClasses; } /** * Defines a new method on the target class * * @param methodName the method name * @param modifiers the modifier bitmask, made by OR'ing constants from ASM's {@link Opcodes} interface * @param signature the method signature, on standard JVM notation * @param methodBody the method body */ public void defineMethod(String methodName, int modifiers, String signature, CodeBlock methodBody) { this.methods.add(new MethodDefinition(methodName, modifiers, signature, methodBody)); } /** * Defines a new field on the target class * * @param fieldName the field name * @param modifiers the modifier bitmask, made by OR'ing constants from ASM's {@link Opcodes} interface * @param signature the field signature, on standard JVM notation * @param value the default value (null for JVM default) * @return the new field definition for further modification */ public FieldDefinition defineField(String fieldName, int modifiers, String signature, Object value) { FieldDefinition field = new FieldDefinition(fieldName, modifiers, signature, value); this.fields.add(field); return field; } /** * Defines a default constructor on the target class */ public void defineDefaultConstructor() { defineDefaultConstructor(ACC_PUBLIC); } public void defineDefaultConstructor(int access) { defineMethod("", access, sig(void.class), newCodeBlock().aload(0) .invokespecial(superClassName, "", sig(void.class)).voidreturn()); } /** * Convert this class representation to JDK bytecode * * @return the bytecode representation */ public byte[] toBytes() { return toBytes(JDKVersion.V1_6); } public void addAnnotation(VisibleAnnotation annotation) { annotations.add(annotation); } /** * Convert this class representation to JDK bytecode * * @param version the desired JDK version * @return the bytecode representation of this class */ public byte[] toBytes(JDKVersion version) { ClassNode node = new ClassNode(); node.version = version.getVer(); node.access = this.access | ACC_SUPER; node.name = this.className; node.superName = this.superClassName; node.sourceFile = this.sourceFile; node.sourceDebug = this.sourceDebug; if (parentClassName != null) { node.visitOuterClass(parentClassName, null, null); } for (ChildEntry child : childClasses) { node.visitInnerClass(child.getClassName(), className, child.getInnerName(), child.getAccess()); } if (!this.interfaces.isEmpty()) { node.interfaces.addAll(this.interfaces); } for (MethodDefinition def : methods) { node.methods.add(def.getMethodNode()); } for (FieldDefinition def : fields) { node.fields.add(def.getFieldNode()); } if (node.visibleAnnotations == null) { node.visibleAnnotations = new ArrayList(); } for (VisibleAnnotation a : annotations) { node.visibleAnnotations.add(a.getNode()); } ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); node.accept(cw); return cw.toByteArray(); } private static final class ChildEntry { public final String innerName; public final JiteClass jiteClass; public ChildEntry(String innerName, JiteClass jiteClass) { this.innerName = innerName; this.jiteClass = jiteClass; } public int getAccess() { return jiteClass.getAccess(); } public String getClassName() { return jiteClass.getClassName(); } public String getInnerName() { return innerName; } public JiteClass getJiteClass() { return jiteClass; } } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/MethodDefinition.java000066400000000000000000000045231405156103600301770ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript; import java.util.ArrayList; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.LocalVariableNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.TryCatchBlockNode; /** * @author qmx */ public class MethodDefinition { private final String methodName; private final int modifiers; private final String signature; private final CodeBlock methodBody; public MethodDefinition(String methodName, int modifiers, String signature, CodeBlock methodBody) { this.methodName = methodName; this.modifiers = modifiers; this.signature = signature; this.methodBody = methodBody; } public String getMethodName() { return methodName; } public int getModifiers() { return modifiers; } public CodeBlock getMethodBody() { return methodBody; } public String getSignature() { return signature; } public MethodNode getMethodNode() { MethodNode method = new MethodNode(getModifiers(), getMethodName(), getSignature(), null, null); method.visibleAnnotations = new ArrayList(); method.instructions.add(getMethodBody().getInstructionList()); for (TryCatchBlockNode tryCatchBlockNode : getMethodBody().getTryCatchBlockList()) { method.tryCatchBlocks.add(tryCatchBlockNode); } for (LocalVariableNode localVariableNode : getMethodBody().getLocalVariableList()) { method.localVariables.add(localVariableNode); } for (VisibleAnnotation annotation : methodBody.getAnnotations()) { method.visibleAnnotations.add(annotation.getNode()); } return method; } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/VisibleAnnotation.java000066400000000000000000000032301405156103600303700ustar00rootroot00000000000000package me.qmx.jitescript; import static me.qmx.jitescript.util.CodegenUtils.ci; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.tree.AnnotationNode; public class VisibleAnnotation { private final AnnotationVisitor node; public VisibleAnnotation(Class type) { this(ci(type)); } public VisibleAnnotation(String desc) { this.node = new AnnotationNode(desc); } private VisibleAnnotation(AnnotationVisitor node) { this.node = node; } public AnnotationNode getNode() { return (AnnotationNode) node; } public VisibleAnnotation value(String name, Object value) { node.visit(name, value); return this; } public VisibleAnnotation enumValue(String name, Enum value) { enumValue(name, ci(value.getClass()), value.name()); return this; } public VisibleAnnotation enumValue(String name, String desc, String value) { node.visitEnum(name, desc, value); return this; } public VisibleAnnotation annotationValue(String name, Class type) { return annotationValue(name, ci(type)); } public VisibleAnnotation annotationValue(String name, String desc) { return new VisibleAnnotation(node.visitAnnotation(name, desc)); } public AnnotationArrayValue arrayValue(String name) { return new AnnotationArrayValue(name, node.visitArray(name)); } public AnnotationArrayValue arrayValue(String name, Object... values) { AnnotationArrayValue array = arrayValue(name); for (Object value : values) { array.add(value); } return array; } } jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/util/000077500000000000000000000000001405156103600250545ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/main/java/me/qmx/jitescript/util/CodegenUtils.java000066400000000000000000000200411405156103600303010ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript.util; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Type; import java.util.Arrays; import java.util.Map; /** * @author headius */ public final class CodegenUtils { private CodegenUtils() { } /** * Creates a dotted class name from a path/package name */ public static String c(String p) { return p.replace('/', '.'); } /** * Creates a class path name, from a Class. */ public static String p(Class n) { return n.getName().replace('.', '/'); } /** * Creates a class identifier of form Labc/abc;, from a Class. */ public static String ci(Class n) { if (n.isArray()) { n = n.getComponentType(); if (n.isPrimitive()) { if (n == Byte.TYPE) { return "[B"; } else if (n == Boolean.TYPE) { return "[Z"; } else if (n == Short.TYPE) { return "[S"; } else if (n == Character.TYPE) { return "[C"; } else if (n == Integer.TYPE) { return "[I"; } else if (n == Float.TYPE) { return "[F"; } else if (n == Double.TYPE) { return "[D"; } else if (n == Long.TYPE) { return "[J"; } else { throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); } } else { return "[" + ci(n); } } else { if (n.isPrimitive()) { if (n == Byte.TYPE) { return "B"; } else if (n == Boolean.TYPE) { return "Z"; } else if (n == Short.TYPE) { return "S"; } else if (n == Character.TYPE) { return "C"; } else if (n == Integer.TYPE) { return "I"; } else if (n == Float.TYPE) { return "F"; } else if (n == Double.TYPE) { return "D"; } else if (n == Long.TYPE) { return "J"; } else if (n == Void.TYPE) { return "V"; } else { throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); } } else { return "L" + p(n) + ";"; } } } /** * Creates a human-readable representation, from a Class. */ public static String human(Class n) { return n.getCanonicalName(); } /** * Create a method signature from the given param types and return values */ public static String sig(Class retval, Class... params) { return sigParams(params) + ci(retval); } public static String sig(Class[] retvalParams) { Class[] justParams = new Class[retvalParams.length - 1]; System.arraycopy(retvalParams, 1, justParams, 0, justParams.length); return sigParams(justParams) + ci(retvalParams[0]); } public static String sig(Class retval, String descriptor, Class... params) { return sigParams(descriptor, params) + ci(retval); } public static String sigParams(Class... params) { StringBuilder signature = new StringBuilder("("); for (int i = 0; i < params.length; i++) { signature.append(ci(params[i])); } signature.append(")"); return signature.toString(); } public static String sigParams(String descriptor, Class... params) { StringBuilder signature = new StringBuilder("("); signature.append(descriptor); for (int i = 0; i < params.length; i++) { signature.append(ci(params[i])); } signature.append(")"); return signature.toString(); } public static String pretty(Class retval, Class... params) { return prettyParams(params) + human(retval); } public static String prettyParams(Class... params) { StringBuilder signature = new StringBuilder("("); for (int i = 0; i < params.length; i++) { signature.append(human(params[i])); if (i < params.length - 1) { signature.append(','); } } signature.append(")"); return signature.toString(); } public static Class[] params(Class... classes) { return classes; } public static Class[] params(Class cls, int times) { Class[] classes = new Class[times]; Arrays.fill(classes, cls); return classes; } public static Class[] params(Class cls1, Class clsFill, int times) { Class[] classes = new Class[times + 1]; Arrays.fill(classes, clsFill); classes[0] = cls1; return classes; } public static Class[] params(Class cls1, Class cls2, Class clsFill, int times) { Class[] classes = new Class[times + 2]; Arrays.fill(classes, clsFill); classes[0] = cls1; classes[1] = cls2; return classes; } public static String getAnnotatedBindingClassName(String javaMethodName, String typeName, boolean isStatic, int required, int optional, boolean multi, boolean framed) { String commonClassSuffix; if (multi) { commonClassSuffix = (isStatic ? "$s$" : "$i$") + javaMethodName; } else { commonClassSuffix = (isStatic ? "$s$" : "$i$") + required + "$" + optional + "$" + javaMethodName; } return typeName + commonClassSuffix; } public static void visitAnnotationFields(AnnotationVisitor visitor, Map fields) { for (Map.Entry fieldEntry : fields.entrySet()) { Object value = fieldEntry.getValue(); if (value.getClass().isArray()) { Object[] values = (Object[]) value; AnnotationVisitor arrayV = visitor.visitArray(fieldEntry.getKey()); for (int i = 0; i < values.length; i++) { arrayV.visit(null, values[i]); } arrayV.visitEnd(); } else if (value.getClass().isEnum()) { visitor.visitEnum(fieldEntry.getKey(), ci(value.getClass()), value.toString()); } else if (value instanceof Class) { visitor.visit(fieldEntry.getKey(), Type.getType((Class) value)); } else { visitor.visit(fieldEntry.getKey(), value); } } } public static Class getBoxType(Class type) { if (type == int.class) { return Integer.class; } else if (type == byte.class) { return Byte.class; } else if (type == short.class) { return Short.class; } else if (type == char.class) { return Character.class; } else if (type == long.class) { return Long.class; } else if (type == float.class) { return Float.class; } else if (type == double.class) { return Double.class; } else if (type == boolean.class) { return Boolean.class; } else { throw new RuntimeException("Not a native type: " + type); } } } jitescript-jitescript-0.4.3/src/test/000077500000000000000000000000001405156103600176235ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/test/java/000077500000000000000000000000001405156103600205445ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/test/java/me/000077500000000000000000000000001405156103600211455ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/test/java/me/qmx/000077500000000000000000000000001405156103600217525ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/test/java/me/qmx/jitescript/000077500000000000000000000000001405156103600241325ustar00rootroot00000000000000jitescript-jitescript-0.4.3/src/test/java/me/qmx/jitescript/AnnotationsTest.java000066400000000000000000000143601405156103600301360ustar00rootroot00000000000000package me.qmx.jitescript; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import static me.qmx.jitescript.util.CodegenUtils.ci; import static me.qmx.jitescript.util.CodegenUtils.p; import static me.qmx.jitescript.util.CodegenUtils.sig; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arrays; import me.qmx.jitescript.JiteClassTest.DynamicClassLoader; import org.junit.Test; public class AnnotationsTest { @Test public void testAnnotationWithScalarValue() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); VisibleAnnotation annotation = new VisibleAnnotation(ScalarAnnotation.class); annotation.value("breakfastItem", "Waffles!"); addAnnotation(annotation); } }; Class clazz = new DynamicClassLoader().define(jiteClass); ScalarAnnotation annotation = clazz.getAnnotation(ScalarAnnotation.class); assertNotNull("ScalarAnnotation was not on class", annotation); assertEquals(annotation.breakfastItem(), "Waffles!"); } @Test public void testAnnotationWithArrayValue() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); VisibleAnnotation annotation = new VisibleAnnotation(AnnotationWithArray.class); annotation.arrayValue("favoriteColors", "pink", "purple", "green"); addAnnotation(annotation); } }; Class clazz = new DynamicClassLoader().define(jiteClass); AnnotationWithArray annotation = clazz.getAnnotation(AnnotationWithArray.class); assertNotNull("AnnotationWithArray was not on class", annotation); assertTrue(Arrays.equals(annotation.favoriteColors(), new String[]{"pink", "purple", "green"})); } @Test public void testAnnotationWithAnnotationValue() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); VisibleAnnotation annotation = new VisibleAnnotation(AnnotationWithAnnotation.class); annotation.annotationValue("element", ScalarAnnotation.class).value("breakfastItem", "Pancakes!"); addAnnotation(annotation); } }; Class clazz = new DynamicClassLoader().define(jiteClass); AnnotationWithAnnotation annotation = clazz.getAnnotation(AnnotationWithAnnotation.class); assertNotNull("AnnotationWithAnnotation was not on class", annotation); assertEquals(annotation.element().breakfastItem(), "Pancakes!"); } @Test public void testAnnotationWithEnumValue() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); VisibleAnnotation annotation = new VisibleAnnotation(AnnotationWithEnum.class); annotation.enumValue("color", Colors.PINK); addAnnotation(annotation); } }; Class clazz = new DynamicClassLoader().define(jiteClass); AnnotationWithEnum annotation = clazz.getAnnotation(AnnotationWithEnum.class); assertNotNull("AnnotationWithEnum was not on class", annotation); assertEquals(annotation.color(), Colors.PINK); } @Test public void testAnnotatedMethod() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); defineMethod("annotatedMethod", ACC_PUBLIC, sig(String.class), new CodeBlock() { { ldc("Sausages!"); areturn(); annotation(ScalarAnnotation.class).value("breakfastItem", "Sausages!"); } }); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Method method = clazz.getMethod("annotatedMethod"); ScalarAnnotation annotation = method.getAnnotation(ScalarAnnotation.class); assertNotNull("ScalarAnnotation was not on method", annotation); assertEquals(annotation.breakfastItem(), "Sausages!"); } @Test public void testAnnotatedField() throws Exception { JiteClass jiteClass = new JiteClass("AnnotatedClass", p(Object.class), new String[0]) { { defineDefaultConstructor(); defineField("annotatedField", ACC_PUBLIC, ci(String.class), null).addAnnotation( new VisibleAnnotation(ScalarAnnotation.class).value("breakfastItem", "Toast!")); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Field field = clazz.getField("annotatedField"); ScalarAnnotation annotation = field.getAnnotation(ScalarAnnotation.class); assertNotNull("ScalarAnnotation was not on field", annotation); assertEquals(annotation.breakfastItem(), "Toast!"); } @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) public @interface ScalarAnnotation { String breakfastItem(); } @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) public @interface AnnotationWithArray { String[] favoriteColors(); } @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) public @interface AnnotationWithAnnotation { ScalarAnnotation element(); } @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) public @interface AnnotationWithEnum { Colors color(); } public enum Colors { PINK, GREEN, PURPLE } } jitescript-jitescript-0.4.3/src/test/java/me/qmx/jitescript/JiteClassTest.java000066400000000000000000000154141405156103600275230ustar00rootroot00000000000000/** * Copyright 2012 Douglas Campos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.qmx.jitescript; import static me.qmx.jitescript.CodeBlock.newCodeBlock; import static me.qmx.jitescript.util.CodegenUtils.c; import static me.qmx.jitescript.util.CodegenUtils.ci; import static me.qmx.jitescript.util.CodegenUtils.p; import static me.qmx.jitescript.util.CodegenUtils.sig; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.junit.Assert; import org.junit.Test; /** * @author qmx */ public class JiteClassTest { public static class DynamicClassLoader extends ClassLoader { public Class define(JiteClass jiteClass) { byte[] classBytes = jiteClass.toBytes(); return super.defineClass(c(jiteClass.getClassName()), classBytes, 0, classBytes.length); } } @Test public void testDSL() throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { final String className = "helloTest"; JiteClass jiteClass = new JiteClass(className) { { // you can use the pre-constructor style defineMethod("main", ACC_PUBLIC | ACC_STATIC, sig(void.class, String[].class), new CodeBlock() { { ldc("helloWorld"); getstatic(p(System.class), "out", ci(PrintStream.class)); swap(); invokevirtual(p(PrintStream.class), "println", sig(void.class, Object.class)); voidreturn(); } }); // or use chained api defineMethod("hello", ACC_PUBLIC | ACC_STATIC, sig(String.class), newCodeBlock().ldc("helloWorld").areturn()); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Method helloMethod = clazz.getMethod("hello"); Object result = helloMethod.invoke(null); Assert.assertEquals("helloWorld", result); Method mainMethod = clazz.getMethod("main", String[].class); mainMethod.invoke(null, (Object) new String[]{}); } @Test public void testInterfaceImpl() throws IllegalAccessException, InstantiationException { String className = "Test"; JiteClass jiteClass = new JiteClass(className, new String[]{p(Runnable.class)}) { { defineDefaultConstructor(); defineMethod("run", ACC_PUBLIC, sig(void.class), newCodeBlock().ldc("Test").aprintln().voidreturn()); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Object o = clazz.newInstance(); assertTrue(o instanceof Runnable); } public static class LOL { } @Test public void generateClassWithSuperclasses() throws IllegalAccessException, InstantiationException { String className = "Teste"; String superClass = p(LOL.class); JiteClass jiteClass = new JiteClass(className, superClass, new String[]{}) { { defineDefaultConstructor(); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Object o = clazz.newInstance(); assertTrue(o instanceof LOL); } public static class NondefaultConstructor { public String foo = "hello"; } @Test public void superclassHashNondefaultConstructor() throws IllegalAccessException, InstantiationException { String className = "Sub"; String superClass = p(NondefaultConstructor.class); JiteClass jiteClass = new JiteClass(className, superClass, new String[]{}) { { defineDefaultConstructor(); } }; Class clazz = new DynamicClassLoader().define(jiteClass); NondefaultConstructor o = (NondefaultConstructor) clazz.newInstance(); assertEquals("hello", o.foo); } @Test public void testFields() throws Exception { JiteClass jiteClass = new JiteClass("testFields", p(Object.class), new String[0]) { { defineField("foo", ACC_PUBLIC | ACC_STATIC, ci(String.class), "bar"); } }; Class clazz = new DynamicClassLoader().define(jiteClass); Field foo = clazz.getDeclaredField("foo"); assertEquals("foo field was not a string", String.class, foo.getType()); assertEquals("foo field was not set to 'bar'", "bar", foo.get(null)); } @Test(expected = IllegalAccessException.class) public void testPrivateClass() throws Exception { JiteClass jiteClass = new JiteClass("Test", new String[0]) { { setAccess(ACC_PRIVATE); defineDefaultConstructor(); } }; Class clazz = new DynamicClassLoader().define(jiteClass); clazz.newInstance(); } @Test(expected = IllegalAccessException.class) public void testPrivateConstructor() throws Exception { JiteClass jiteClass = new JiteClass("Test", new String[0]) { { defineDefaultConstructor(ACC_PRIVATE); } }; Class clazz = new DynamicClassLoader().define(jiteClass); clazz.newInstance(); } @Test public void testPrivateInnerClass() throws Exception { JiteClass parent = new JiteClass("test/Parent") { { setAccess(ACC_PUBLIC); defineDefaultConstructor(); addChildClass(new JiteClass(getClassName() + "$Child") { { setAccess(ACC_PRIVATE); defineDefaultConstructor(); } }); } }; DynamicClassLoader classLoader = new DynamicClassLoader(); Class parentClazz = classLoader.define(parent); for (JiteClass child : parent.getChildClasses()) { Class childClazz = classLoader.define(child); assertFalse(childClazz.getConstructor(new Class[0]).isAccessible()); } } } jitescript-jitescript-0.4.3/support/000077500000000000000000000000001405156103600175715ustar00rootroot00000000000000jitescript-jitescript-0.4.3/support/formatter.properties000066400000000000000000000575411405156103600237260ustar00rootroot00000000000000eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=51 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=true org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=136 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true