< prev index next >

src/java.desktop/share/classes/com/sun/beans/introspect/MethodInfo.java

Print this page


   1 /*
   2  * Copyright (c) 2014, 2016, 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
  23  * questions.
  24  */
  25 
  26 package com.sun.beans.introspect;
  27 
  28 import com.sun.beans.TypeResolver;
  29 import com.sun.beans.finder.MethodFinder;
  30 
  31 import java.lang.reflect.Method;
  32 import java.lang.reflect.Modifier;
  33 import java.lang.reflect.Type;
  34 import java.util.ArrayList;
  35 import java.util.Arrays;
  36 import java.util.Collections;
  37 import java.util.Comparator;
  38 import java.util.List;
  39 



  40 final class MethodInfo {
  41     final Method method;
  42     final Class<?> type;
  43 
  44     MethodInfo(Method method, Class<?> type) {
  45         this.method = method;
  46         this.type = type;
  47     }
  48 
  49     MethodInfo(Method method, Type type) {
  50         this.method = method;
  51         this.type = resolve(method, type);
  52     }
  53 
  54     boolean isThrow(Class<?> exception) {
  55         for (Class<?> type : this.method.getExceptionTypes()) {
  56             if (type == exception) {
  57                 return true;
  58             }
  59         }


 124                 final Class<?> aparam = aparams[i];
 125                 final Class<?> bparam = bparams[i];
 126                 if (aparam == bparam) {
 127                     continue;
 128                 }
 129                 cmp = aparam.getName().compareTo(bparam.getName());
 130                 if (cmp != 0) {
 131                     return cmp;
 132                 }
 133             }
 134             final Class<?> aret = a.getReturnType();
 135             final Class<?> bret = b.getReturnType();
 136             if (aret == bret) {
 137                 return 0;
 138             }
 139 
 140             // Super type comes last: Integer, Number, Object
 141             if (aret.isAssignableFrom(bret)) {
 142                 return 1;
 143             }

 144             return -1;
 145         }


 146 
 147         static final MethodOrder instance = new MethodOrder();
 148     }
 149 }
   1 /*
   2  * Copyright (c) 2014, 2018, 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
  23  * questions.
  24  */
  25 
  26 package com.sun.beans.introspect;
  27 



  28 import java.lang.reflect.Method;
  29 import java.lang.reflect.Modifier;
  30 import java.lang.reflect.Type;
  31 import java.util.ArrayList;

  32 import java.util.Collections;
  33 import java.util.Comparator;
  34 import java.util.List;
  35 
  36 import com.sun.beans.TypeResolver;
  37 import com.sun.beans.finder.MethodFinder;
  38 
  39 final class MethodInfo {
  40     final Method method;
  41     final Class<?> type;
  42 
  43     MethodInfo(Method method, Class<?> type) {
  44         this.method = method;
  45         this.type = type;
  46     }
  47 
  48     MethodInfo(Method method, Type type) {
  49         this.method = method;
  50         this.type = resolve(method, type);
  51     }
  52 
  53     boolean isThrow(Class<?> exception) {
  54         for (Class<?> type : this.method.getExceptionTypes()) {
  55             if (type == exception) {
  56                 return true;
  57             }
  58         }


 123                 final Class<?> aparam = aparams[i];
 124                 final Class<?> bparam = bparams[i];
 125                 if (aparam == bparam) {
 126                     continue;
 127                 }
 128                 cmp = aparam.getName().compareTo(bparam.getName());
 129                 if (cmp != 0) {
 130                     return cmp;
 131                 }
 132             }
 133             final Class<?> aret = a.getReturnType();
 134             final Class<?> bret = b.getReturnType();
 135             if (aret == bret) {
 136                 return 0;
 137             }
 138 
 139             // Super type comes last: Integer, Number, Object
 140             if (aret.isAssignableFrom(bret)) {
 141                 return 1;
 142             }
 143             if (bret.isAssignableFrom(aret)) {
 144                 return -1;
 145             }
 146             return aret.getName().compareTo(bret.getName());
 147         }
 148 
 149         static final MethodOrder instance = new MethodOrder();
 150     }
 151 }
< prev index next >