Skip to content

Commit

Permalink
Modify ant target -compile-classes
Browse files Browse the repository at this point in the history
Here 'modulesourcepath' attribute specifies the location of the input source
files for multi module compilation.

This patches the native Java modules: java.base and java.logging

- For gov.nasa.jpf to be able to reference the package java.base/sun.net.www.protocol.http

      --add-exports java.base/sun.net.www.protocol.http=ALL-UNNAMED

      This fixes the error:
      [javac] classes/gov.nasa.jpf/gov/nasa/jpf/CachedROHttpConnection.java:
              error: package sun.net.www.protocol.http is not visible
      [javac] (package sun.net.www.protocol.http is declared in module java.base, which does not export it to unanmed module)

- For java.base to be able to reference classes from the unnamed module (here in our case the package gov.nasa.jpf.annotation)

      --add-reads java.base=ALL-UNNAMED

      This fixes the error:

      [javac] classes/modules/java.base/java/lang/Thread.java:
              error: package gov.nasa.jpf.annotation does not exist

      [javac] classes/modules/java.base/java/io/OutputStreamWriter.java:
              error: package gov.nasa.jpf.vm does not exist

JPF code except for the java model classes is compiled into the default unnamed module.
  • Loading branch information
gayanW committed May 7, 2018
1 parent 4154c2a commit 880b4ca
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,35 @@

<target name="-compile-classes" if="have_classes" depends="-compile-annotations,-compile-main" >
<mkdir dir="build/classes"/>
<javac srcdir="src/classes" destdir="build/classes" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}">

<!-- compile non-module classes -->
<javac srcdir="src/classes/gov:src/classes/org" destdir="build/classes" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
<compilerarg value="-Xlint:all"/>
<classpath>
<path refid="lib.path"/>
<pathelement location="build/annotations"/>
</classpath>

<compilerarg value="--patch-module"/>
<compilerarg value="java.base=src/classes/modules/java.base"/>

<compilerarg value="--patch-module"/>
<compilerarg value="java.logging=src/classes/modules/java.logging"/>

<compilerarg value="--add-exports"/>
<compilerarg value="java.base/sun.net.www.protocol.http=ALL-UNNAMED"/>

<compilerarg value="--add-reads"/>
<compilerarg value="java.base=ALL-UNNAMED"/>
</javac>

<!-- patch model classes -->
<javac modulesourcepath="src/classes/modules" destdir="build/classes" includeantruntime="false"
debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
<compilerarg value="-Xlint:all"/>

<compilerarg value="--patch-module"/>
<compilerarg value="java.base=src/classes/modules/java.base"/>

<compilerarg value="--patch-module"/>
<compilerarg value="java.logging=src/classes/modules/java.logging"/>
</javac>
</target>

Expand Down

0 comments on commit 880b4ca

Please sign in to comment.