Ejemplo n.º 1
0
 @Override
 public void visitLineNumber(final int line, final Label start) {
   checkStartCode();
   checkEndCode();
   checkUnsignedShort(line, "Invalid line number");
   checkLabel(start, true, "start label");
   super.visitLineNumber(line, start);
 }
Ejemplo n.º 2
0
 @Override
 public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) {
   checkEndCode();
   checkStartCode();
   checkLabel(dflt, false, "default label");
   checkNonDebugLabel(dflt);
   if (keys == null || labels == null || keys.length != labels.length) {
     throw new IllegalArgumentException("There must be the same number of keys and labels");
   }
   for (int i = 0; i < labels.length; ++i) {
     checkLabel(labels[i], false, "label at index " + i);
     checkNonDebugLabel(labels[i]);
   }
   super.visitLookupSwitchInsn(dflt, keys, labels);
   usedLabels.add(dflt);
   for (int i = 0; i < labels.length; ++i) {
     usedLabels.add(labels[i]);
   }
   ++insnCount;
 }
Ejemplo n.º 3
0
 @Override
 public void visitLabel(final Label label) {
   checkStartCode();
   checkEndCode();
   checkLabel(label, false, "label");
   if (labels.get(label) != null) {
     throw new IllegalArgumentException("Already visited label");
   }
   labels.put(label, insnCount);
   super.visitLabel(label);
 }
Ejemplo n.º 4
0
 @Override
 public void visitJumpInsn(final int opcode, final Label label) {
   checkStartCode();
   checkEndCode();
   checkOpcode(opcode, 6);
   checkLabel(label, false, "label");
   checkNonDebugLabel(label);
   super.visitJumpInsn(opcode, label);
   usedLabels.add(label);
   ++insnCount;
 }
Ejemplo n.º 5
0
 @Override
 public void visitTryCatchBlock(
     final Label start, final Label end, final Label handler, final String type) {
   checkStartCode();
   checkEndCode();
   checkLabel(start, false, "start label");
   checkLabel(end, false, "end label");
   checkLabel(handler, false, "handler label");
   checkNonDebugLabel(start);
   checkNonDebugLabel(end);
   checkNonDebugLabel(handler);
   if (labels.get(start) != null || labels.get(end) != null || labels.get(handler) != null) {
     throw new IllegalStateException("Try catch blocks must be visited before their labels");
   }
   if (type != null) {
     checkInternalName(type, "type");
   }
   super.visitTryCatchBlock(start, end, handler, type);
   handlers.add(start);
   handlers.add(end);
 }
Ejemplo n.º 6
0
 @Override
 public AnnotationVisitor visitLocalVariableAnnotation(
     int typeRef,
     TypePath typePath,
     Label[] start,
     Label[] end,
     int[] index,
     String desc,
     boolean visible) {
   checkStartCode();
   checkEndCode();
   int sort = typeRef >>> 24;
   if (sort != TypeReference.LOCAL_VARIABLE && sort != TypeReference.RESOURCE_VARIABLE) {
     throw new IllegalArgumentException(
         "Invalid type reference sort 0x" + Integer.toHexString(sort));
   }
   CheckClassAdapter.checkTypeRefAndPath(typeRef, typePath);
   checkDesc(desc, false);
   if (start == null
       || end == null
       || index == null
       || end.length != start.length
       || index.length != start.length) {
     throw new IllegalArgumentException(
         "Invalid start, end and index arrays (must be non null and of identical length");
   }
   for (int i = 0; i < start.length; ++i) {
     checkLabel(start[i], true, "start label");
     checkLabel(end[i], true, "end label");
     checkUnsignedShort(index[i], "Invalid variable index");
     int s = labels.get(start[i]).intValue();
     int e = labels.get(end[i]).intValue();
     if (e < s) {
       throw new IllegalArgumentException(
           "Invalid start and end labels (end must be greater than start)");
     }
   }
   return super.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, desc, visible);
 }
Ejemplo n.º 7
0
 @Override
 public void visitLocalVariable(
     final String name,
     final String desc,
     final String signature,
     final Label start,
     final Label end,
     final int index) {
   checkStartCode();
   checkEndCode();
   checkUnqualifiedName(version, name, "name");
   checkDesc(desc, false);
   checkLabel(start, true, "start label");
   checkLabel(end, true, "end label");
   checkUnsignedShort(index, "Invalid variable index");
   int s = labels.get(start).intValue();
   int e = labels.get(end).intValue();
   if (e < s) {
     throw new IllegalArgumentException(
         "Invalid start and end labels (end must be greater than start)");
   }
   super.visitLocalVariable(name, desc, signature, start, end, index);
 }
Ejemplo n.º 8
0
 @Override
 public void visitTableSwitchInsn(
     final int min, final int max, final Label dflt, final Label... labels) {
   checkStartCode();
   checkEndCode();
   if (max < min) {
     throw new IllegalArgumentException(
         "Max = " + max + " must be greater than or equal to min = " + min);
   }
   checkLabel(dflt, false, "default label");
   checkNonDebugLabel(dflt);
   if (labels == null || labels.length != max - min + 1) {
     throw new IllegalArgumentException("There must be max - min + 1 labels");
   }
   for (int i = 0; i < labels.length; ++i) {
     checkLabel(labels[i], false, "label at index " + i);
     checkNonDebugLabel(labels[i]);
   }
   super.visitTableSwitchInsn(min, max, dflt, labels);
   for (int i = 0; i < labels.length; ++i) {
     usedLabels.add(labels[i]);
   }
   ++insnCount;
 }