< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java

Print this page


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


1723                  l = l.tail) {
1724                 MethodSymbol meth = findAccessMethod(a.type, l.head.fst);
1725                 buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd)));
1726             }
1727             return new Attribute.Compound(a.type, buf.toList());
1728         }
1729 
1730         MethodSymbol findAccessMethod(Type container, Name name) {
1731             CompletionFailure failure = null;
1732             try {
1733                 for (Symbol sym : container.tsym.members().getSymbolsByName(name)) {
1734                     if (sym.kind == MTH && sym.type.getParameterTypes().length() == 0)
1735                         return (MethodSymbol) sym;
1736                 }
1737             } catch (CompletionFailure ex) {
1738                 failure = ex;
1739             }
1740             // The method wasn't found: emit a warning and recover
1741             JavaFileObject prevSource = log.useSource(requestingOwner.classfile);
1742             try {

1743                 if (failure == null) {
1744                     log.warning("annotation.method.not.found",
1745                                 container,
1746                                 name);
1747                 } else {
1748                     log.warning("annotation.method.not.found.reason",
1749                                 container,
1750                                 name,
1751                                 failure.getDetailValue());//diagnostic, if present

1752                 }
1753             } finally {
1754                 log.useSource(prevSource);
1755             }
1756             // Construct a new method type and symbol.  Use bottom
1757             // type (typeof null) as return type because this type is
1758             // a subtype of all reference types and can be converted
1759             // to primitive types by unboxing.
1760             MethodType mt = new MethodType(List.<Type>nil(),
1761                                            syms.botType,
1762                                            List.<Type>nil(),
1763                                            syms.methodClass);
1764             return new MethodSymbol(PUBLIC | ABSTRACT, name, mt, container.tsym);
1765         }
1766 
1767         Attribute result;
1768         Type type;
1769         Attribute deproxy(Type t, Attribute a) {
1770             Type oldType = type;
1771             try {


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


1723                  l = l.tail) {
1724                 MethodSymbol meth = findAccessMethod(a.type, l.head.fst);
1725                 buf.append(new Pair<>(meth, deproxy(meth.type.getReturnType(), l.head.snd)));
1726             }
1727             return new Attribute.Compound(a.type, buf.toList());
1728         }
1729 
1730         MethodSymbol findAccessMethod(Type container, Name name) {
1731             CompletionFailure failure = null;
1732             try {
1733                 for (Symbol sym : container.tsym.members().getSymbolsByName(name)) {
1734                     if (sym.kind == MTH && sym.type.getParameterTypes().length() == 0)
1735                         return (MethodSymbol) sym;
1736                 }
1737             } catch (CompletionFailure ex) {
1738                 failure = ex;
1739             }
1740             // The method wasn't found: emit a warning and recover
1741             JavaFileObject prevSource = log.useSource(requestingOwner.classfile);
1742             try {
1743                 if (lintClassfile) {
1744                     if (failure == null) {
1745                         log.warning("annotation.method.not.found",
1746                                     container,
1747                                     name);
1748                     } else {
1749                         log.warning("annotation.method.not.found.reason",
1750                                     container,
1751                                     name,
1752                                     failure.getDetailValue());//diagnostic, if present
1753                     }
1754                 }
1755             } finally {
1756                 log.useSource(prevSource);
1757             }
1758             // Construct a new method type and symbol.  Use bottom
1759             // type (typeof null) as return type because this type is
1760             // a subtype of all reference types and can be converted
1761             // to primitive types by unboxing.
1762             MethodType mt = new MethodType(List.<Type>nil(),
1763                                            syms.botType,
1764                                            List.<Type>nil(),
1765                                            syms.methodClass);
1766             return new MethodSymbol(PUBLIC | ABSTRACT, name, mt, container.tsym);
1767         }
1768 
1769         Attribute result;
1770         Type type;
1771         Attribute deproxy(Type t, Attribute a) {
1772             Type oldType = type;
1773             try {


< prev index next >