src/java.base/share/classes/java/lang/invoke/LambdaForm.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/share/classes/java/lang/invoke

src/java.base/share/classes/java/lang/invoke/LambdaForm.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1017                 this.resolvedHandle = basicInvokerType.invokers().basicInvoker();
1018                 this.member = resolvedHandle.internalMemberName();
1019             } else {
1020                 // necessary to pass BigArityTest
1021                 this.member = Invokers.invokeBasicMethod(basicInvokerType);
1022             }
1023             assert(isInvokeBasic());
1024         }
1025 
1026         private boolean isInvokeBasic() {
1027             return member != null &&
1028                    member.isMethodHandleInvoke() &&
1029                    "invokeBasic".equals(member.getName());
1030         }
1031 
1032         // The next 3 constructors are used to break circular dependencies on MH.invokeStatic, etc.
1033         // Any LambdaForm containing such a member is not interpretable.
1034         // This is OK, since all such LFs are prepared with special primitive vmentry points.
1035         // And even without the resolvedHandle, the name can still be compiled and optimized.
1036         NamedFunction(Method method) {
1037             this(new MemberName(method));
1038         }
1039         NamedFunction(Field field) {
1040             this(new MemberName(field));
1041         }
1042         NamedFunction(MemberName member) {
1043             this.member = member;
1044             this.resolvedHandle = null;
1045         }
1046 
1047         MethodHandle resolvedHandle() {
1048             if (resolvedHandle == null)  resolve();
1049             return resolvedHandle;
1050         }
1051 
1052         void resolve() {
1053             resolvedHandle = DirectMethodHandle.make(member);
1054         }
1055 
1056         @Override
1057         public boolean equals(Object other) {
1058             if (this == other) return true;
1059             if (other == null) return false;
1060             if (!(other instanceof NamedFunction)) return false;


   1 /*
   2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1017                 this.resolvedHandle = basicInvokerType.invokers().basicInvoker();
1018                 this.member = resolvedHandle.internalMemberName();
1019             } else {
1020                 // necessary to pass BigArityTest
1021                 this.member = Invokers.invokeBasicMethod(basicInvokerType);
1022             }
1023             assert(isInvokeBasic());
1024         }
1025 
1026         private boolean isInvokeBasic() {
1027             return member != null &&
1028                    member.isMethodHandleInvoke() &&
1029                    "invokeBasic".equals(member.getName());
1030         }
1031 
1032         // The next 3 constructors are used to break circular dependencies on MH.invokeStatic, etc.
1033         // Any LambdaForm containing such a member is not interpretable.
1034         // This is OK, since all such LFs are prepared with special primitive vmentry points.
1035         // And even without the resolvedHandle, the name can still be compiled and optimized.
1036         NamedFunction(Method method) {
1037             this(MemberName.make(method));
1038         }
1039         NamedFunction(Field field) {
1040             this(MemberName.make(field));
1041         }
1042         NamedFunction(MemberName member) {
1043             this.member = member;
1044             this.resolvedHandle = null;
1045         }
1046 
1047         MethodHandle resolvedHandle() {
1048             if (resolvedHandle == null)  resolve();
1049             return resolvedHandle;
1050         }
1051 
1052         void resolve() {
1053             resolvedHandle = DirectMethodHandle.make(member);
1054         }
1055 
1056         @Override
1057         public boolean equals(Object other) {
1058             if (this == other) return true;
1059             if (other == null) return false;
1060             if (!(other instanceof NamedFunction)) return false;


src/java.base/share/classes/java/lang/invoke/LambdaForm.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File