1 /*
2 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
3 * @LastModified: Oct 2017
4 */
5 /*
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21 package com.sun.org.apache.bcel.internal.generic;
22
23 import com.sun.org.apache.bcel.internal.Const;
42 import java.util.Arrays;
43 import java.util.Comparator;
44 import java.util.HashMap;
45 import java.util.List;
46 import java.util.Map;
47 import java.util.Stack;
48
49 /**
50 * Template class for building up a method. This is done by defining exception
51 * handlers, adding thrown exceptions, local variables and attributes, whereas
52 * the `LocalVariableTable' and `LineNumberTable' attributes will be set
53 * automatically for the code. Use stripAttributes() if you don't like this.
54 *
55 * While generating code it may be necessary to insert NOP operations. You can
56 * use the `removeNOPs' method to get rid off them. The resulting method object
57 * can be obtained via the `getMethod()' method.
58 *
59 * @version $Id: MethodGen.java 1749603 2016-06-21 20:50:19Z ggregory $
60 * @see InstructionList
61 * @see Method
62 */
63 public class MethodGen extends FieldGenOrMethodGen {
64
65 private String class_name;
66 private Type[] arg_types;
67 private String[] arg_names;
68 private int max_locals;
69 private int max_stack;
70 private InstructionList il;
71 private boolean strip_attributes;
72 private final List<LocalVariableGen> variable_vec = new ArrayList<>();
73 private final List<LocalVariableGen> type_vec = new ArrayList<>();
74 private final List<LineNumberGen> line_number_vec = new ArrayList<>();
75 private final List<CodeExceptionGen> exception_vec = new ArrayList<>();
76 private final List<String> throws_vec = new ArrayList<>();
77 private final List<Attribute> code_attrs_vec = new ArrayList<>();
78
79 private List<AnnotationEntryGen>[] param_annotations; // Array of lists containing AnnotationGen objects
80 private boolean hasParameterAnnotations = false;
81 private boolean haveUnpackedParameterAnnotations = false;
|
1 /*
2 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 package com.sun.org.apache.bcel.internal.generic;
21
22 import com.sun.org.apache.bcel.internal.Const;
41 import java.util.Arrays;
42 import java.util.Comparator;
43 import java.util.HashMap;
44 import java.util.List;
45 import java.util.Map;
46 import java.util.Stack;
47
48 /**
49 * Template class for building up a method. This is done by defining exception
50 * handlers, adding thrown exceptions, local variables and attributes, whereas
51 * the `LocalVariableTable' and `LineNumberTable' attributes will be set
52 * automatically for the code. Use stripAttributes() if you don't like this.
53 *
54 * While generating code it may be necessary to insert NOP operations. You can
55 * use the `removeNOPs' method to get rid off them. The resulting method object
56 * can be obtained via the `getMethod()' method.
57 *
58 * @version $Id: MethodGen.java 1749603 2016-06-21 20:50:19Z ggregory $
59 * @see InstructionList
60 * @see Method
61 * @LastModified: Oct 2017
62 */
63 public class MethodGen extends FieldGenOrMethodGen {
64
65 private String class_name;
66 private Type[] arg_types;
67 private String[] arg_names;
68 private int max_locals;
69 private int max_stack;
70 private InstructionList il;
71 private boolean strip_attributes;
72 private final List<LocalVariableGen> variable_vec = new ArrayList<>();
73 private final List<LocalVariableGen> type_vec = new ArrayList<>();
74 private final List<LineNumberGen> line_number_vec = new ArrayList<>();
75 private final List<CodeExceptionGen> exception_vec = new ArrayList<>();
76 private final List<String> throws_vec = new ArrayList<>();
77 private final List<Attribute> code_attrs_vec = new ArrayList<>();
78
79 private List<AnnotationEntryGen>[] param_annotations; // Array of lists containing AnnotationGen objects
80 private boolean hasParameterAnnotations = false;
81 private boolean haveUnpackedParameterAnnotations = false;
|