Initial import
[jpf-core.git] / src / main / gov / nasa / jpf / vm / BootstrapMethodInfo.java
1 /*
2  * Copyright (C) 2014, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The Java Pathfinder core (jpf-core) platform is licensed under the
7  * Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  *        http://www.apache.org/licenses/LICENSE-2.0. 
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  */
18 package gov.nasa.jpf.vm;
19
20 /**
21  * @author Nastaran Shafiei <nastaran.shafiei@gmail.com>
22  *
23  * For now, this is only used to capture boostrap methods for lambda expression,
24  * which link the method representing the lambda body to a single abstract method 
25  * (SAM) declared in a functional interface. References to bootstrap methods are
26  * provided by the invokedynamic bytecode instruction. 
27  */
28 public class BootstrapMethodInfo {
29   
30   int lambdaRefKind;
31   
32   // method capturing lambda body to be linked to the function method of function object
33   MethodInfo lambdaBody;
34   
35   // class containing lamabda expression
36   ClassInfo enclosingClass;
37   
38   // descriptor of a SAM declared within the functional interface   
39   String samDescriptor;
40   
41   public BootstrapMethodInfo(int lambdaRefKind, ClassInfo enclosingClass, MethodInfo lambdaBody, String samDescriptor) {
42     this.lambdaRefKind = lambdaRefKind;
43     this.enclosingClass = enclosingClass;
44     this.lambdaBody = lambdaBody;
45     this.samDescriptor = samDescriptor;
46   }
47   
48   @Override
49   public String toString() {
50     return "BootstrapMethodInfo[" + enclosingClass.getName() + "." + lambdaBody.getBaseName() + 
51         "[SAM descriptor:" + samDescriptor + "]]";
52   }
53   
54   public MethodInfo getLambdaBody() {
55     return lambdaBody;
56   }
57   
58   public String getSamDescriptor() {
59     return samDescriptor;
60   }
61   
62   public int getLambdaRefKind () {
63     return lambdaRefKind;
64   }
65 }