src/java.base/share/classes/java/lang/invoke/InfoFromMemberName.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/InfoFromMemberName.java

Print this page


   1 /*
   2  * Copyright (c) 2012, 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


 116             else
 117                 return defc.getDeclaredMethod(getName(), getMethodType().parameterArray());
 118         } else if (MethodHandleNatives.refKindIsConstructor(refKind)) {
 119             if (isPublic)
 120                 return defc.getConstructor(getMethodType().parameterArray());
 121             else
 122                 return defc.getDeclaredConstructor(getMethodType().parameterArray());
 123         } else if (MethodHandleNatives.refKindIsField(refKind)) {
 124             if (isPublic)
 125                 return defc.getField(getName());
 126             else
 127                 return defc.getDeclaredField(getName());
 128         } else {
 129             throw new IllegalArgumentException("referenceKind="+refKind);
 130         }
 131     }
 132 
 133     private static MemberName convertToMemberName(byte refKind, Member mem) throws IllegalAccessException {
 134         if (mem instanceof Method) {
 135             boolean wantSpecial = (refKind == REF_invokeSpecial);
 136             return new MemberName((Method) mem, wantSpecial);
 137         } else if (mem instanceof Constructor) {
 138             return new MemberName((Constructor) mem);
 139         } else if (mem instanceof Field) {
 140             boolean isSetter = (refKind == REF_putField || refKind == REF_putStatic);
 141             return new MemberName((Field) mem, isSetter);
 142         }
 143         throw new InternalError(mem.getClass().getName());
 144     }
 145 }
   1 /*
   2  * Copyright (c) 2012, 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


 116             else
 117                 return defc.getDeclaredMethod(getName(), getMethodType().parameterArray());
 118         } else if (MethodHandleNatives.refKindIsConstructor(refKind)) {
 119             if (isPublic)
 120                 return defc.getConstructor(getMethodType().parameterArray());
 121             else
 122                 return defc.getDeclaredConstructor(getMethodType().parameterArray());
 123         } else if (MethodHandleNatives.refKindIsField(refKind)) {
 124             if (isPublic)
 125                 return defc.getField(getName());
 126             else
 127                 return defc.getDeclaredField(getName());
 128         } else {
 129             throw new IllegalArgumentException("referenceKind="+refKind);
 130         }
 131     }
 132 
 133     private static MemberName convertToMemberName(byte refKind, Member mem) throws IllegalAccessException {
 134         if (mem instanceof Method) {
 135             boolean wantSpecial = (refKind == REF_invokeSpecial);
 136             return MemberName.make((Method) mem, wantSpecial);
 137         } else if (mem instanceof Constructor) {
 138             return MemberName.make((Constructor) mem);
 139         } else if (mem instanceof Field) {
 140             boolean isSetter = (refKind == REF_putField || refKind == REF_putStatic);
 141             return MemberName.make((Field) mem, isSetter);
 142         }
 143         throw new InternalError(mem.getClass().getName());
 144     }
 145 }
src/java.base/share/classes/java/lang/invoke/InfoFromMemberName.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File