Version 1.7.4
[gae.git] / java / src / main / com / google / appengine / tools / development / agent / impl / NonRecordingGeneratorAdapter.java
blobead589a061fc8ecded6c9f2fc199f5eaa5bc9ddc
1 // Copyright 2012 Google Inc. All Rights Reserved.
3 package com.google.appengine.tools.development.agent.impl;
5 import org.objectweb.asm.MethodVisitor;
6 import org.objectweb.asm.Type;
7 import org.objectweb.asm.commons.GeneratorAdapter;
9 /**
10 * A subclass of {@link GeneratorAdapter} that does not record the types of newly added local
11 * variables, thereby avoiding a bug in {@link org.objectweb.asm.commons.LocalVariablesSorter}.
12 * <p>
13 * Use this class instead of {@link GeneratorAdapter} to avoid <a
14 * href="http://forge.ow2.org/tracker/index.php?func=detail&aid=316352&group_id=23&atid=100023">ASM
15 * bug #316352 </a>
16 * <p>
20 public class NonRecordingGeneratorAdapter extends GeneratorAdapter {
22 public NonRecordingGeneratorAdapter(
23 MethodVisitor methodVisitor, int access, String name, String desc) {
24 super(methodVisitor, access, name, desc);
27 /**
28 * Creates a new local variable of the given type.
30 * @param type the type of the local variable to be created.
31 * @return the identifier of the newly created local variable.
33 @Override
34 public int newLocal(final Type type) {
35 int local = nextLocal;
36 nextLocal += type.getSize();
37 setLocalType(local, type);
38 return local;