Package kilim.tools

Class Asm

java.lang.Object
kilim.tools.Asm

public class Asm extends Object
This is a replacement for the jasmin bytecode assembler and uses the same syntax. The main reason for writing it is that jasmin (v 2.1 at the time of writing) didn't correcly support annotations. That is, the annotations inserted by jasmin don't show up in java.lang.reflect.Method, even though the annotations are in the class file. It was easier to write this tool than to release a separate fix for jasmin.
 Usage: java kilim.tools.Asm [options] invalid input: '<'.j file(s)>
 Options:
      -d  : output directory (default: '.')
      -f       : force            (default: false) write output even if output file is newer than source
      -q       : quiet            (default: verbose)
      -nf      : no stack frames  (default: compute stack frames)
 
If stack frames are requested (default), the version of the class file is V1_6, otherwise it is V1_5.
  • Field Details

    • quiet

      static boolean quiet
    • force

      static boolean force
    • outputDir

      static String outputDir
    • wsPattern

      static Pattern wsPattern
    • commentPattern

      static Pattern commentPattern
    • eofOK

      private boolean eofOK
    • cv

      private org.objectweb.asm.ClassWriter cv
    • mv

      private org.objectweb.asm.MethodVisitor mv
    • maxLocals

      private int maxLocals
    • maxStack

      private int maxStack
    • declaredLabels

      private HashSet<String> declaredLabels
    • labels

      private HashMap<String,org.objectweb.asm.Label> labels
    • className

      private String className
    • methodName

      private String methodName
    • fileName

      private String fileName
    • line

      private Line line
    • bufferedLine

      private Line bufferedLine
    • lastMatch

      private Matcher lastMatch
    • lastPattern

      private Pattern lastPattern
    • reader

      private LineNumberReader reader
    • skip

      private boolean skip
    • modifiers

      static HashMap<String,Integer> modifiers
    • classNamePatternStr

      private static String classNamePatternStr
    • modifierPatternStr

      private static String modifierPatternStr
    • classPattern

      private static Pattern classPattern
    • superPattern

      private static Pattern superPattern
    • implementsPattern

      private static Pattern implementsPattern
    • namePatternStr

      private static String namePatternStr
    • descPatternStr

      private static String descPatternStr
    • fieldPattern

      private static Pattern fieldPattern
    • methodNamePatternStr

      private static String methodNamePatternStr
    • methodPattern

      private static Pattern methodPattern
    • throwsPattern

      private static Pattern throwsPattern
    • labelPattern

      private static Pattern labelPattern
    • localsPattern

      static Pattern localsPattern
    • stackPattern

      static Pattern stackPattern
    • catchPattern

      static Pattern catchPattern
    • annotationPattern

      static Pattern annotationPattern
    • opcodeStrs

      static String[] opcodeStrs
    • computeFrames

      private static boolean computeFrames
    • opcodeMap

      private static final HashMap<String,Integer> opcodeMap
    • visitTypes

      private static final byte[] visitTypes
    • INSN

      private static final int INSN
      See Also:
    • VAR

      private static final int VAR
      See Also:
    • LDC

      private static final int LDC
      See Also:
    • JUMP

      private static final int JUMP
      See Also:
    • TABLESWITCH

      private static final int TABLESWITCH
      See Also:
    • LOOKUPSWITCH

      private static final int LOOKUPSWITCH
      See Also:
    • FIELD

      private static final int FIELD
      See Also:
    • METHOD

      private static final int METHOD
      See Also:
    • TYPE

      private static final int TYPE
      See Also:
    • MULTIANEWARRAY

      private static final int MULTIANEWARRAY
      See Also:
    • INT

      private static final int INT
      See Also:
    • IINC

      private static final int IINC
      See Also:
    • insnPattern

      static final Pattern insnPattern
    • quotedPattern

      static final Pattern quotedPattern
    • casePattern

      static final Pattern casePattern
    • methodInvokePattern

      static final Pattern methodInvokePattern
    • fieldSpecPattern

      static final Pattern fieldSpecPattern
    • eofSeen

      boolean eofSeen
  • Constructor Details

  • Method Details

    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • parse

      public Asm parse() throws IOException
      Throws:
      IOException
    • parseClass

      private void parseClass()
    • parseModifiers

      private int parseModifiers(String s)
    • parseSuper

      private String parseSuper()
    • parseInterfaces

      private String[] parseInterfaces()
    • parseClassBody

      private void parseClassBody()
    • parseField

      private void parseField()
    • parseMethod

      private void parseMethod()
    • parseMethodExceptions

      private String[] parseMethodExceptions()
    • parseMethodBody

      private void parseMethodBody()
    • parseLabel

      private void parseLabel()
    • checkLabelDeclarations

      private void checkLabelDeclarations()
    • parseMethodDirective

      private void parseMethodDirective()
    • parseAnnotation

      private void parseAnnotation()
    • parseInstructions

      private void parseInstructions()
    • opcheck

      private void opcheck(String errMessage, String operand)
    • parseValue

      private Object parseValue(String s, boolean isDoubleWord)
    • parseInt

      int parseInt(String s)
    • parseLong

      long parseLong(String s)
    • parseFloat

      float parseFloat(String s)
    • parseDouble

      double parseDouble(String s)
    • getLabel

      org.objectweb.asm.Label getLabel(String s)
    • err

      private void err(String s)
    • readLine

      private Line readLine()
    • putBackLine

      private void putBackLine()
    • getLine

      private Line getLine()
    • match

      boolean match(String s, Pattern p)
    • lineMatch

      boolean lineMatch(Pattern p)
    • group

      String group(int i)
    • groupCount

      int groupCount()
    • split

      static String[] split(Pattern p, String s)
    • outputName

      private String outputName()
    • check

      private boolean check()
    • write

      private void write() throws IOException
      Throws:
      IOException
    • mkdir

      private static void mkdir(String dir) throws IOException
      Throws:
      IOException
    • getDirName

      private static String getDirName(String className)
    • parseArgs

      private static List<String> parseArgs(String[] args)