2012-06-06 22 views
8

我試圖用OpenJDK7編譯我對OSGi規範4.3 OSGi包,但我得到的錯誤:如何使用OpenJDK 7編譯mavenized OSGi 4.3包?

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile (default-compile) on project example: Compilation failure 
[ERROR] /tmp/baka/example/src/main/java/org/example/Activator.java:[14,24] error: type ServiceReference does not take parameters 

這裏是我的Activator.java:

package org.example; 

import org.osgi.framework.BundleActivator; 
import org.osgi.framework.BundleContext; 
import org.osgi.framework.ServiceReference; 

public class Activator implements BundleActivator { 
    @Override 
    public void start(BundleContext bundleContext) throws Exception { 
     ServiceReference<Runnable> ref = bundleContext.getServiceReference(Runnable.class); 
    } 

    @Override 
    public void stop(BundleContext bundleContext) throws Exception { 
    } 
} 

和我的pom.xml:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>org.example</groupId> 
    <artifactId>example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>bundle</packaging> 

    <name>example</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.osgi</groupId> 
      <artifactId>org.osgi.core</artifactId> 
      <version>4.3.0</version> 
     </dependency> 
    </dependencies> 


    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.felix</groupId> 
       <artifactId>maven-bundle-plugin</artifactId> 
       <version>2.3.7</version> 
       <extensions>true</extensions> 
       <configuration> 
        <instructions> 
         <Private-Package>org.example</Private-Package> 
         <Bundle-Activator>org.example.Activator</Bundle-Activator> 
        </instructions> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

當我使用OpenJDK 6時不會出現此錯誤。任何提示如何使它與OpenJDK 7一起工作?

回答