我有Kotlin代码:
cluster.removeIf { t: SolutionElement -> t.timeStart < minimumDate } //Clusters.kt:66
其中cluster对象是kotlin Mutable列表。当我尝试在Google App Engine标准环境中运行此代码时出现错误:
java.lang.NoClassDefFoundError: java/util/function/Predicate
at com.google.appengine.runtime.Request.process-4a2a3dcd2b375db7(Request.java)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:820)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.lang.ClassLoader.loadClass(ClassLoader.java:375)
at net.toolla.teamly.services.matcher.Clusters.removeExpired(Clusters.kt:66)
at net.toolla.teamly.services.matcher.Clusters.pickMore(Clusters.kt:31)
at net.toolla.teamly.services.matcher.BestMatchWorker.getSolutionElements(BestMatchWorker.java:232)
at net.toolla.teamly.services.matcher.BestMatchWorker.match(BestMatchWorker.java:116)
at net.toolla.teamly.services.matcher.MatcherService.doPost(MatcherService.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:297)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:320)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:312)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: java.util.function.Predicate
at com.google.appengine.runtime.Request.process-4a2a3dcd2b375db7(Request.java)
在这个模块的build.gradle中,我有:
compileKotlin{
kotlinOptions{
jvmTarget = 1.6
}
}
没有该参数错误是:
Uncaught exception from servlet
java.lang.NoClassDefFoundError: net/toolla/teamly/services/matcher/Clusters$removeExpired$1
其中“removeExpired”是包含上述行的函数的名称。
我将上面的代码更改为一些不太方便和较旧的语法,但知道如何使用更新的技术会很棒。
答案 0 :(得分:1)
类java.util.function.Predicate
是在Java 8中引入的。所以用8运行它。关于
...
* @since 1.8
*/
@FunctionalInterface
public interface Predicate<T> {
关于该错误:
java.lang.NoClassDefFoundError: 净/ toolla / teamly /服务/匹配/集群$ removeExpired $ 1
确保您的classpath
答案 1 :(得分:1)
您可以使用Kotlin标准库中的removeAll method代替removeIf
,这是JDK 8中的方法,因此不支持JDK 6,所有JDK版本都支持该库。{3}}。