View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at 
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software 
11   * distributed under the License is distributed on an "AS IS" BASIS, 
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  
17  
18  package org.apache.jdo.impl.enhancer.classfile;
19  
20  import java.util.Hashtable;
21  
22  /***
23   * Environment in which to decode the attributes of a CodeAttribute.
24   */
25  class CodeEnv {
26      /* The constant pool */
27      private ConstantPool constantPool;
28  
29      /* hash table mapping byte code offset to InsnTarget */
30      private Hashtable targets = new Hashtable(7);
31  
32      CodeEnv(ConstantPool constantPool) {
33          this.constantPool = constantPool;
34      }
35  
36      final InsnTarget getTarget(int offset) {
37          Integer off = new Integer(offset);
38          InsnTarget targ = (InsnTarget)targets.get(off);
39          if (targ == null) {
40              targ = new InsnTarget(offset);
41              targets.put(off, targ);
42          }
43          return targ;
44      }
45  
46      final InsnTarget findTarget(int offset) {
47          Integer off = new Integer(offset);
48          return (InsnTarget)targets.get(off);
49      }
50  
51      final ConstantPool pool() {
52          return constantPool;
53      }
54  }