src/jdk/internal/dynalink/beans/OverloadedDynamicMethod.java

changeset 963
e2497b11a021
parent 962
ac62e33a99b0
child 1205
4112748288bb
child 1539
684d430470f6
     1.1 --- a/src/jdk/internal/dynalink/beans/OverloadedDynamicMethod.java	Wed Aug 20 10:25:28 2014 +0200
     1.2 +++ b/src/jdk/internal/dynalink/beans/OverloadedDynamicMethod.java	Wed Aug 20 10:26:01 2014 +0200
     1.3 @@ -148,7 +148,6 @@
     1.4          }
     1.5      }
     1.6  
     1.7 -    @SuppressWarnings("fallthrough")
     1.8      @Override
     1.9      public MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
    1.10          final MethodType callSiteType = callSiteDescriptor.getMethodType();
    1.11 @@ -207,7 +206,7 @@
    1.12              case 1: {
    1.13                  // Very lucky, we ended up with a single candidate method handle based on the call site signature; we
    1.14                  // can link it very simply by delegating to the SingleDynamicMethod.
    1.15 -                invokables.iterator().next().getInvocation(callSiteDescriptor, linkerServices);
    1.16 +                return invokables.iterator().next().getInvocation(callSiteDescriptor, linkerServices);
    1.17              }
    1.18              default: {
    1.19                  // We have more than one candidate. We have no choice but to link to a method that resolves overloads on
    1.20 @@ -237,6 +236,12 @@
    1.21          return false;
    1.22      }
    1.23  
    1.24 +    @Override
    1.25 +    public boolean isConstructor() {
    1.26 +        assert !methods.isEmpty();
    1.27 +        return methods.getFirst().isConstructor();
    1.28 +    }
    1.29 +
    1.30      ClassLoader getClassLoader() {
    1.31          return classLoader;
    1.32      }
    1.33 @@ -304,6 +309,11 @@
    1.34       * @param method a method to add
    1.35       */
    1.36      public void addMethod(final SingleDynamicMethod method) {
    1.37 +        assert constructorFlagConsistent(method);
    1.38          methods.add(method);
    1.39      }
    1.40 +
    1.41 +    private boolean constructorFlagConsistent(final SingleDynamicMethod method) {
    1.42 +        return methods.isEmpty()? true : (methods.getFirst().isConstructor() == method.isConstructor());
    1.43 +    }
    1.44  }

mercurial