Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Java 11 compatibility #2812

Closed
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,8 +1,8 @@
language: java

jdk:
- openjdk8
- openjdk11

# Replace Travis's default Maven installation step with a no-op.
# This avoids redundantly pre-running 'mvn install -DskipTests' every time.
install: true
Expand Down
1 change: 1 addition & 0 deletions docs/Changelog.md
Expand Up @@ -5,6 +5,7 @@
- Add Way Property Set for the UK (#2818)
- Fixes surefire test failure during build (#2816)
- Improve documentation for `mode` routing parameter (#2809)
- Make OTP run on Java 11 (#2812)

## 1.4 (2019-07-30)

Expand Down
72 changes: 55 additions & 17 deletions pom.xml
Expand Up @@ -78,7 +78,7 @@
</scm>

<properties>
<geotools.version>20.1</geotools.version>
<geotools.version>21.2</geotools.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see Geotools 21 was the first version with Java 11 compatibility. I assume we aren't jumping to an even newer Geotools because of the transitive dependency on JTS, which has changed its package name and will conflict with other OTP dependencies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tought that 21.2 is the newest stable version: https://github.com/geotools/geotools/tags

Or would you like to use 22-RC?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I suppose it is. I saw 23-SNAPSHOT and must have assumed there was already a 22 release. But now I see 22 is also still in SNAPSHOT. In that case then there's no question, 21.2 is fine.

<geotools.wfs.version>16.5</geotools.wfs.version>
<jackson.version>2.9.7</jackson.version>
<jersey.version>2.18</jersey.version>
Expand Down Expand Up @@ -172,11 +172,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<!-- Target Java versions -->
<source>1.8</source>
<target>1.8</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -208,15 +207,35 @@
<docsDir>${project.build.directory}/site/enunciate</docsDir>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<archive>
<manifestEntries>
<!-- For Java 11 Modules, specify a module name. Do not create module-info.java until all
our dependencies specify a module name. -->
<Automatic-Module-Name>org.opentripplanner.otp</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>

</plugin>
<plugin>
<!-- This plugin must be configured both here (for attach-javadoc during release)
and in "reports" (for site generation), preferably with identical version numbers. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<version>3.1.1</version>
<configuration>
<!-- Turn off Java 8 strict Javadoc checking -->
<additionalparam>-Xdoclint:none</additionalparam>
<!-- Turn off strict Javadoc checking -->
<doclint>none</doclint>
<!--
Exclude this package as it inherits from a JAI (https://www.oracle.com/technetwork/java/iio-141084.html) type
whose sources are hard to discover by the JavaDoc tool.
-->
<excludePackageNames>org.opentripplanner.graph_builder.module.ned:*</excludePackageNames>
</configuration>
<executions>
<!-- Compress Javadoc into JAR and include that JAR when deploying. -->
Expand All @@ -231,7 +250,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down Expand Up @@ -259,10 +278,29 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<!--
Intentionally an old version as the combination of Junit 5, Java 11 and Surefire was causing issues.
https://github.com/opentripplanner/OpenTripPlanner/pull/2812/commits/c811224f8467699ee70684e9f6b00d3ad803dbeb
-->
<version>2.19.1</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that in c42ca0c you downgraded this due to a corrupted stream error. I'd like to eventually find and fix the root problem. Can you provide a link to the ticket you referenced in your commit message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, I will try again and clarify the commit message.

<configuration>
<argLine>-Xmx2G</argLine>
<argLine>-Dfile.encoding=UTF-8</argLine>
<!-- we have to fork the JVM during tests so that the argLine is passed along -->
<forkCount>3</forkCount>
<!-- enable the restricted reflection under Java 11 so that the ObjectDiffer works -->
<argLine>
-Xmx2G
-Dfile.encoding=UTF-8
--illegal-access=permit
--add-opens java.base/java.lang.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/jdk.internal.util=ALL-UNNAMED
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens java.base/jdk.internal.module=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
<!-- Jenkins needs XML test reports to determine whether the build is stable. -->
<disableXmlReport>false</disableXmlReport>
</configuration>
Expand Down Expand Up @@ -310,7 +348,7 @@
properly if some input files are missing a terminating newline) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -390,10 +428,10 @@
(for attach-javadoc during release), preferably with identical version numbers. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<version>3.1.1</version>
<configuration>
<!-- Turn off Java 8 strict Javadoc checking -->
<additionalparam>-Xdoclint:none</additionalparam>
<doclint>false</doclint>
</configuration>
<reportSets>
<reportSet>
Expand Down Expand Up @@ -461,17 +499,17 @@
<!-- GEOTOOLS includes JTS as a transitive dependency. -->
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<artifactId>gt-main</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<artifactId>gt-geojson</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing3D</artifactId>
<artifactId>gt-referencing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
Expand Down
Expand Up @@ -35,7 +35,7 @@ public DoubleComparator(Map<QuadEdge,Double> map) {
* @param qeB
* quad edge to compare
* @return
* 1 if double value associated to qeA < double
* 1 if double value associated to qeA less than double
* value associated to qeB,
* 0 if values are equals,
* -1 otherwise
Expand Down
Expand Up @@ -64,7 +64,7 @@ else if (CRS.getAxisOrder(destCrs) == CRS.AxisOrder.EAST_NORTH)
if (!destCrs.equals(sourceCrs)) {
transform = true;

// find the transformation, being strict about datums &c.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like ampersand-c. as a way to write "et cetera", as the ampersand is a ligature of Latin "et". It's fine to remove it though if it might confuse some people.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, Javadoc is interpreting this as in HTML. Now I see why it's removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, Java 11 is way more strict with these HTML entities.

A big problem where also the < and > characters. I got a little creative and converted to unicode characters where possible. If not I just spelled them out with words.

Copy link
Member

@abyrd abyrd Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my commits on the 2.x port, I used &gt; to replace > in some places, but that makes it kind of unreadable in a text editor. Although I managed to eliminate all the error messages, the most complete "solution" was to just turn off the doclint in the config in the POM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: In Intellij Ctrl+J (at leas with mac shortcuts) displays the formated text - I find it easier to read. So ,I tend to favor good readable formated JavaDoc over it to be easy to read in plain text.

// find the transformation, being strict about datums etc.
mathTransform = CRS.findMathTransform(sourceCrs, destCrs, false);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/opentripplanner/analyst/core/Tile.java
Expand Up @@ -30,10 +30,14 @@
* Result is stored in image pixel as a signed byte.
*
* So:
* <pre>
* {@code
* -119 to +119 are interpreted literally,
* +120 means >= +120,
* -120 means <= -120,
* -128 means "unreachable".
* }
* </pre>
*/
t2gran marked this conversation as resolved.
Show resolved Hide resolved
public abstract class Tile {

Expand Down
42 changes: 24 additions & 18 deletions src/main/java/org/opentripplanner/api/model/WalkStep.java
Expand Up @@ -17,28 +17,34 @@
/**
* Represents one instruction in walking directions. Three examples from New York City:
* <p>
* Turn onto Broadway from W 57th St (coming from 7th Ave): <br/>
* distance = 100 (say) <br/>
* walkDirection = RIGHT <br/>
* streetName = Broadway <br/>
* everything else null/false <br/>
* Turn onto Broadway from W 57th St (coming from 7th Ave):
* <pre>
* distance = 100 (say)
* walkDirection = RIGHT
* streetName = Broadway
* everything else null/false
* </pre>
* </p>
* <p>
* Now, turn from Broadway onto Central Park S via Columbus Circle <br/>
* distance = 200 (say) <br/>
* walkDirection = CIRCLE_COUNTERCLOCKWISE <br/>
* streetName = Central Park S <br/>
* exit = 1 (first exit) <br/>
* immediately everything else false <br/>
* Now, turn from Broadway onto Central Park S via Columbus Circle
* <pre>
* distance = 200 (say)
* walkDirection = CIRCLE_COUNTERCLOCKWISE
* streetName = Central Park S
* exit = 1 (first exit)
* immediately everything else false
* </pre>
* </p>
* <p>
* Instead, go through the circle to continue on Broadway <br/>
* distance = 100 (say) <br/>
* walkDirection = CIRCLE_COUNTERCLOCKWISE <br/>
* streetName = Broadway <br/>
* exit = 3 <br/>
* stayOn = true <br/>
* everything else false <br/>
* Instead, go through the circle to continue on Broadway
* <pre>
* distance = 100 (say)
* walkDirection = CIRCLE_COUNTERCLOCKWISE
* streetName = Broadway
* exit = 3
* stayOn = true
* everything else false
* </pre>
* </p>
* */
public class WalkStep {
t2gran marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Expand Up @@ -42,7 +42,7 @@
* Tile rendering goes through TileRendererManager which select the appropriate renderer for the
* given layer.
*
* @see TileRendererManager
* @see org.opentripplanner.inspector.TileRendererManager
* @see TileRenderer
*
* @author laurent
Expand Down
Expand Up @@ -47,10 +47,10 @@
*
* Example of request:
*
* <code>
* {@code
* http://localhost:8080/otp-rest-servlet/ws/isochrone?routerId=bordeaux&algorithm=accSampling&fromPlace=47.059,-0.880&date=2013/10/01&time=12:00:00&maxWalkDistance=1000&mode=WALK,TRANSIT&cutoffSec=1800&cutoffSec=3600
* </code>
*
* }
*
* @author laurent
*/
@Path("/routers/{routerId}/isochrone")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/opentripplanner/api/resource/Routers.java
Expand Up @@ -62,7 +62,7 @@
* For example:
*
* GET http://localhost/otp-rest-servlet/ws/routers
* will retrieve a list of all registered routerId -> Graph mappings and their geographic bounds.
* will retrieve a list of all registered routerId Graph mappings and their geographic bounds.
*
* GET http://localhost/otp-rest-servlet/ws/routers/london
* will return status code 200 and a brief description of the 'london' graph including geographic
Expand Down Expand Up @@ -112,7 +112,7 @@ public RouterList getRouterIds() {

/**
* Returns the bounds for a specific routerId, or verifies whether it is registered.
* @returns status code 200 if the routerId is registered, otherwise a 404.
* @return status code 200 if the routerId is registered, otherwise a 404.
*/
@GET @Path("{routerId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + Q, MediaType.TEXT_XML + Q })
Expand Down
Expand Up @@ -97,9 +97,11 @@ public class SIsochrone extends RoutingResource {
* and distortions towards an ellipse will appear if it is transformed/projected to the user location.
* <p>
* An example request may look like this:
* {@code
* localhost:8080/otp-rest-servlet/ws/iso?layers=traveltime&styles=mask&batch=true&fromPlace=51.040193121307176
* %2C-114.04471635818481&toPlace
* =51.09098935%2C-113.95179705&time=2012-06-06T08%3A00%3A00&mode=WALK&maxWalkDistance=10000&walkSpeed=1.38&walkTime=10.7&output=EDGES
* =51.09098935%2C-113.95179705&time=2012-06-06T08%3A00%3A00&mode=WALK&maxWalkDistance=10000&walkSpeed=1.38&walkTime=10.7&output=EDGES
* }
* Though the first parameters (i) layer, (ii) styles and (iii) batch could be discarded.
*
* @param walkmins Maximum number of minutes to walk.
Expand Down
Expand Up @@ -32,9 +32,9 @@
*
* Example of request:
*
* <code>
* {@code
* http://localhost:8080/otp/routers/bordeaux/timegrid?fromPlace=47.059,-0.880&date=2013/10/01&time=12:00:00&maxWalkDistance=1000&maxTimeSec=3600&mode=WALK,TRANSIT
* </code>
* }
*
* @author laurent
*/
Expand Down
Expand Up @@ -5,7 +5,7 @@
import java.util.TimeZone;

/**
* Represents a repeating time period, used for opening hours &c.
* Represents a repeating time period, used for opening hours etc.
* For instance: Monday - Friday 8AM to 8PM, Satuday 10AM to 5PM, Sunday closed.
* For now it is week-based so doesn't handle every possible case, but since it is encapsulated
* that could conceivably be changed.
Expand Down
Expand Up @@ -31,7 +31,7 @@ public final class CompactElevationProfile implements Serializable {
/**
* Compact an elevation profile onto a var-len int packed form (Dlugosz coding).
*
* @param profile The elevation profile to compact
* @param elevation The elevation profile to compact
* @return The compacted format
*/
public static byte[] compactElevationProfile(CoordinateSequence elevation) {
Expand Down
Expand Up @@ -164,11 +164,6 @@ public static LineString uncompactLineString(double xa, double ya, double xb, do
/**
* Same as the other version, but in a var-len int packed form (Dlugosz coding).
*
* @param x0
* @param y0
* @param x1
* @param y1
* @param coords
* @return
*/
public static LineString uncompackLineString(double x0, double y0, double x1, double y1,
Expand Down
Expand Up @@ -338,7 +338,7 @@ public static class Float extends PackedCoordinateSequence {
float[] coords;

/**
* Constructs a packed coordinate sequence from an array of <code>float<code>s
* Constructs a packed coordinate sequence from an array of {@code float}s
*
* @param coords
* @param dimensions
Expand All @@ -356,7 +356,7 @@ public Float(float[] coords, int dimensions) {
}

/**
* Constructs a packed coordinate sequence from an array of <code>double<code>s
* Constructs a packed coordinate sequence from an array of ${@code double}s
*/
public Float(double[] coordinates, int dimensions) {
this.coords = new float[coordinates.length];
Expand Down
Expand Up @@ -48,14 +48,15 @@ public Builder id(String id) {

/**
* Extracts a feed_id from the passed source for a GTFS feed.
* <p/>
* <p>
* This will try to fetch the experimental feed_id field from the feed_info.txt file.
* <p/>
* </p>
* <p>
* If the feed does not contain a feed_info.txt or a feed_id field a default GtfsFeedId will be created.
* </p>
*
* @param source the input source
* @return A GtfsFeedId
* @throws IOException
* @see <a href="http://developer.trimet.org/gtfs_ext.shtml">http://developer.trimet.org/gtfs_ext.shtml</a>
t2gran marked this conversation as resolved.
Show resolved Hide resolved
*/
public Builder fromGtfsFeed(CsvInputSource source) {
Expand Down
Expand Up @@ -23,8 +23,8 @@
* Uses the shapes from GTFS to determine which streets buses drive on. This is used to improve the quality of
* the stop-to-street linkage. It encourages the linker to link to streets where transit actually travels.
*
* GTFS provides a mapping from trips->shapes. This module provides a mapping from stops->trips and shapes->edges.
* Then transitively we get a mapping from stop->edges.
* GTFS provides a mapping from tripsshapes. This module provides a mapping from stopstrips and shapesedges.
* Then transitively we get a mapping from stopedges.
* The edges that "belong" to a stop are favored when linking that stop to the street network.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but I like trips to shapes better than . If the editor do not support UTF-8 or uses the wrong encoding this will not look very nice.

*/
public class BusRouteStreetMatcher implements GraphBuilderModule {
Expand Down