我正在使用插件 org.eclipse.virgo.bundlor 从模板创建 OSGi 清单文件。当我使用 lambdas 时,插件无法正常工作。您能否建议更改我的 maven 文件或替代 bundlor 以允许我使用 lambda?
这是我的 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lamba</groupId>
<artifactId>lamba</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>lamba</name>
<properties>
<java-source-version>1.8</java-source-version>
<java-target-version>1.8</java-target-version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
<version>1.1.2.RELEASE</version>
<dependencies>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.blint</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>${project.artifactId}-bundle-manifest</id>
<phase>prepare-package</phase>
<goals>
<goal>bundlor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java-source-version}</source>
<target>${java-target-version}</target>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
导致问题的代码很简单:
package lamba.internal;
import java.util.function.Supplier;
/**
*
*/
public class HiImpl {
public Supplier<String> p=()->"hi";
}
我的错误是这样的:
[INFO] --- org.eclipse.virgo.bundlor.maven:1.1.2.RELEASE:bundlor (lamba-bundle-manifest) @ lamba ---
java.lang.ArrayIndexOutOfBoundsException: 28712
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.eclipse.virgo.bundlor.support.asm.AsmTypeArtifactAnalyzer.analyse(AsmTypeArtifactAnalyzer.java:37)
at org.eclipse.virgo.bundlor.support.StandardManifestGenerator.analyzeEntry(StandardManifestGenerator.java:114)
at org.eclipse.virgo.bundlor.support.StandardManifestGenerator.analyzeEntries(StandardManifestGenerator.java:99)
at org.eclipse.virgo.bundlor.support.StandardManifestGenerator.generate(StandardManifestGenerator.java:64)
at org.eclipse.virgo.bundlor.maven.plugin.internal.MavenBundlorExecutor.execute(MavenBundlorExecutor.java:68)
at org.eclipse.virgo.bundlor.maven.plugin.BundlorMojo.execute(BundlorMojo.java:222)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Manifest written to '/Users/me/proj/lamba/target/classes/META-INF/MANIFEST.MF'
更新,我尝试使用较新版本的 ASM 库,但没有奏效:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lamba</groupId>
<artifactId>lamba</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>lamba</name>
<properties>
<java-source-version>1.8</java-source-version>
<java-target-version>1.8</java-target-version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.maven</artifactId>
<version>1.1.2.RELEASE</version>
<dependencies>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor</artifactId>
<version>1.1.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.tree</artifactId>
</exclusion>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.virgo.bundlor</groupId>
<artifactId>org.eclipse.virgo.bundlor.blint</artifactId>
<version>1.1.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm</artifactId>
</exclusion>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.tree</artifactId>
</exclusion>
<exclusion>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.objectweb.asm</groupId>
<artifactId>com.springsource.org.objectweb.asm.commons</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<executions>
<execution>
<id>${project.artifactId}-bundle-manifest</id>
<phase>prepare-package</phase>
<goals>
<goal>bundlor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java-source-version}</source>
<target>${java-target-version}</target>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>