Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 8 在简单求值期间,默认方法不可见_Java 8_Apache Camel_Default Method - Fatal编程技术网

Java 8 在简单求值期间,默认方法不可见

Java 8 在简单求值期间,默认方法不可见,java-8,apache-camel,default-method,Java 8,Apache Camel,Default Method,这个问题可以在下面的单元测试中复制,我还没有在tracker中找到它。 本质:接口A有默认方法,接口B扩展了A,在简单的语言求值过程中默认方法是不可见的。 骆驼版本2.16.1。我错过什么了吗 import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.Defaul

这个问题可以在下面的单元测试中复制,我还没有在tracker中找到它。 本质:接口A有默认方法,接口B扩展了A,在简单的语言求值过程中默认方法是不可见的。 骆驼版本2.16.1。我错过什么了吗

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;
import org.junit.Assert;
import org.junit.Test;

public class DefaultMethodIsInvisibleTest {
    @Test
    public void camelSimpleDoesNotSeeDefaultMethod() throws Exception {
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("direct:camelSimpleDoesNotSeeDefaultMethod").log("Result of default method invocation is ${exchangeProperty.myObject.defaultMethod}");
            }
        });
        context.start();

        Exchange incomingExchange = new DefaultExchange(context);
        incomingExchange.setProperty("myObject", new B() {
        });

        Exchange result = context.createProducerTemplate().send("direct:camelSimpleDoesNotSeeDefaultMethod", incomingExchange);

        Assert.assertNull(result.getException());
    }

public static interface A {
    public default String defaultMethod() {
        return "default method result";
    }
}

public static interface B extends A {
}
}
堆栈跟踪:

Caused by: org.apache.camel.language.bean.RuntimeBeanExpressionException: Failed to invoke method: defaultMethod on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: defaultMethod not found on bean: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2@5dafbe45 of type: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2. Exchange[][Message: [Body is null]]
    at org.apache.camel.language.bean.BeanExpression$OgnlInvokeProcessor.process(BeanExpression.java:290)
    at org.apache.camel.language.bean.BeanExpression.evaluate(BeanExpression.java:114)
    ... 46 common frames omitted
Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: defaultMethod not found on bean: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2@5dafbe45 of type: com.ubs.wma.gfi.tradersbook.subscriber.DefaultMethodIsInvisibleTest$2. Exchange[][Message: [Body is null]]
    at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:269)
    at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:183)
    at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:159)

AFAIR不支持接口上的默认方法。欢迎您登录JIRA