2012-06-06 2 views
8

내가 OpenJDK7 사용하여 OSGi 프레임 규격 4.3에 대한 내 OSGi 번들을 컴파일하려고하지만 난 오류가 점점 오전 :OpenJDK 7과 함께 mavenized OSGi 4.3 번들을 컴파일하는 방법은 무엇입니까?

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 파일 : 여기

[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입니다

<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에서 작동하는 방법에 대한 힌트가 있습니까?

답변

11

Java 7에서 javac로 OSGi 소스 코드를 다시 컴파일해야합니다. OSGi는 -target jsr14를 사용하여 Java 6 javac으로 코드를 컴파일했습니다. Java 7 javac은 이러한 클래스 파일에 대한 컴파일 지원을 제거했습니다. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7078419

RG부터는 OSGi는 더 이상 -target jsr14 클래스 파일을 제공하지 않습니다.

가 [2012 10월 31일 업데이트]

은 OSGi 지금 제공하고

는 참조 자바 7에 대한 4.3 jar 파일을 컴파일 http://blog.osgi.org/2012/10/43-companion-code-for-java-7.html

관련 문제