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

Support for Java 8 #258

Closed
thewillyhuman opened this issue Sep 2, 2021 · 4 comments
Closed

Support for Java 8 #258

thewillyhuman opened this issue Sep 2, 2021 · 4 comments

Comments

@thewillyhuman
Copy link
Member

thewillyhuman commented Sep 2, 2021

Hi @labra,

We are using this library for Map Reduce processing within Apache Spark and would like to execute some tests on AWS EMR. Unfortunately, their environment uses Java 1.8 and claims that this library was compiled with Java 1.11.

Exception: java.lang.UnsupportedClassVersionError: es/weso/shex/parser/ShExDocLexer has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0.

@thewillyhuman
Copy link
Member Author

I think that in #4 the build.sbt file was modified to compile within Java 1.8 version. But 6 months ago in commit ea59afe the line

// javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
was commented.

@labra
Copy link
Member

labra commented Sep 2, 2021

OK, let's try to publish all these libraries in Java 1.8...in principle it should be doable.

@thewillyhuman
Copy link
Member Author

The code depending on Java 1.11 is:

def derefRDFJava(iri: IRI): IO[Resource[IO,RDFAsJenaModel]] = for {
str <- IO {
val client = HttpClient.newBuilder().followRedirects(Redirect.ALWAYS).build()
val request: HttpRequest = HttpRequest.newBuilder()
.uri(iri.uri)
.timeout(Duration.ofMinutes(4))
.header("Accept", "text/turtle").GET.build()
println(s"Request: ${request}")
val response = client.send(request, BodyHandlers.ofString)
// println(s"Body: ${response.body()}\nEND BODY (drefJava)")
response.body()
}
rdf <- RDFAsJenaModel.fromString(str,"TURTLE")
} yield rdf
}

@thewillyhuman
Copy link
Member Author

Looks like this was fixed changing previous lines by the following ones:

def derefRDFJava(iri: IRI): IO[Resource[IO,RDFAsJenaModel]] = for {
str <- IO {
// This code is commented because it depends on Java 1.11
/* val client = HttpClient.newBuilder().followRedirects(Redirect.ALWAYS).build()
val request: HttpRequest = HttpRequest.newBuilder()
.uri(iri.uri)
.timeout(Duration.ofMinutes(4))
.header("Accept", "text/turtle").GET.build()
println(s"Request: ${request}")
val response = client.send(request, BodyHandlers.ofString)
// println(s"Body: ${response.body()}\nEND BODY (drefJava)")
response.body() */
// Java 1.8 code
val url: URL = iri.uri.toURL
val conn: HttpURLConnection = url.openConnection().asInstanceOf[HttpURLConnection]
conn.setRequestMethod("GET")
conn.setRequestProperty("Accept", "text/turtle")
conn.setInstanceFollowRedirects(true)
// I think redirects still are required to be done manually. See: https://mkyong.com/java/java-httpurlconnection-follow-redirect-example/
conn.setReadTimeout(5000)
val in = new BufferedReader(new InputStreamReader(conn.getInputStream()))
val str = in.lines().iterator.asScala.mkString
conn.connect()
str
}
rdf <- RDFAsJenaModel.fromString(str,"TURTLE")
} yield rdf

So this issue looks like is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants