weavejester / codox

Clojure documentation tool
Eclipse Public License 1.0
668 stars 97 forks source link

codox crashes under Java 16 #197

Closed cloojure closed 2 years ago

cloojure commented 3 years ago

It works under Java 15. When upgrade to Java 16, get a console error:

> lein codox
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Syntax error (InaccessibleObjectException) compiling at (/tmp/form-init4254302798773385090.clj:1:73).
Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not "opens java.lang" to unnamed module @5d20b857

Full report at:
/tmp/clojure-14388695690223780332.edn
Subprocess failed (exit code: 1)

Full error report:

{:clojure.main/message
 "Syntax error (InaccessibleObjectException) compiling at (/tmp/form-init389832136059657069.clj:1:72).\nUnable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not \"opens java.lang\" to unnamed module @5d20b857\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 72,
  :clojure.error/source "form-init389832136059657069.clj",
  :clojure.error/path "/tmp/form-init389832136059657069.clj",
  :clojure.error/class java.lang.reflect.InaccessibleObjectException,
  :clojure.error/cause
  "Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not \"opens java.lang\" to unnamed module @5d20b857"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/tmp/form-init389832136059657069.clj:1:72).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 72,
     :clojure.error/source "/tmp/form-init389832136059657069.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7652]}
   {:type java.lang.Exception,
    :message "Could not load codox writer codox.writer.html",
    :at [codox.main$writer$fn__749 invoke "main.clj" 16]}
   {:type clojure.lang.Compiler$CompilerException,
    :message "Syntax error macroexpanding def at (html.clj:66:1).",
    :data
    {:clojure.error/phase :execution,
     :clojure.error/line 66,
     :clojure.error/column 1,
     :clojure.error/source "html.clj",
     :clojure.error/symbol def},
    :at [clojure.lang.Compiler$DefExpr eval "Compiler.java" 470]}
   {:type java.lang.reflect.InvocationTargetException,
    :at
    [jdk.internal.reflect.NativeConstructorAccessorImpl
     newInstance0
     "NativeConstructorAccessorImpl.java"
     -2]}
   {:type java.lang.RuntimeException,
    :message
    "Error creating extended parser class: Could not determine whether class 'org.pegdown.Parser$$parboiled' has already been loaded",
    :at [org.parboiled.Parboiled createParser "Parboiled.java" 58]}
   {:type java.lang.RuntimeException,
    :message
    "Could not determine whether class 'org.pegdown.Parser$$parboiled' has already been loaded",
    :at
    [org.parboiled.transform.AsmUtils
     findLoadedClass
     "AsmUtils.java"
     213]}
   {:type java.lang.reflect.InaccessibleObjectException,
    :message
    "Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not \"opens java.lang\" to unnamed module @5d20b857",
    :at
    [java.lang.reflect.AccessibleObject
     checkCanSetAccessible
     "AccessibleObject.java"
     357]}],
  :trace
  [[java.lang.reflect.AccessibleObject
    checkCanSetAccessible
    "AccessibleObject.java"
    357]
   [java.lang.reflect.AccessibleObject
    checkCanSetAccessible
    "AccessibleObject.java"
    297]
   [java.lang.reflect.Method checkCanSetAccessible "Method.java" 199]
   [java.lang.reflect.Method setAccessible "Method.java" 193]
   [org.parboiled.transform.AsmUtils
    findLoadedClass
    "AsmUtils.java"
    206]
   [org.parboiled.transform.ParserTransformer
    transformParser
    "ParserTransformer.java"
    35]
   [org.parboiled.Parboiled createParser "Parboiled.java" 54]
   [org.pegdown.PegDownProcessor <init> "PegDownProcessor.java" 94]
   [org.pegdown.PegDownProcessor <init> "PegDownProcessor.java" 73]
   [jdk.internal.reflect.NativeConstructorAccessorImpl
    newInstance0
    "NativeConstructorAccessorImpl.java"
    -2]
   [jdk.internal.reflect.NativeConstructorAccessorImpl
    newInstance
    "NativeConstructorAccessorImpl.java"
    78]
   [jdk.internal.reflect.DelegatingConstructorAccessorImpl
    newInstance
    "DelegatingConstructorAccessorImpl.java"
    45]
   [java.lang.reflect.Constructor
    newInstanceWithCaller
    "Constructor.java"
    499]
   [java.lang.reflect.Constructor newInstance "Constructor.java" 480]
   [clojure.lang.Compiler$NewExpr eval "Compiler.java" 2619]
   [clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
   [clojure.lang.Compiler eval "Compiler.java" 7186]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6857 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6797 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [codox.main$writer$fn__749 invoke "main.clj" 13]
   [codox.main$writer invokeStatic "main.clj" 12]
   [codox.main$writer invoke "main.clj" 9]
   [codox.main$generate_docs invokeStatic "main.clj" 122]
   [codox.main$generate_docs invoke "main.clj" 116]
   [user$eval843 invokeStatic "form-init389832136059657069.clj" 1]
   [user$eval843 invoke "form-init389832136059657069.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.Compiler loadFile "Compiler.java" 7578]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause
  "Unable to make protected final java.lang.Class java.lang.ClassLoader.findLoadedClass(java.lang.String) accessible: module java.base does not \"opens java.lang\" to unnamed module @5d20b857",
  :phase :compile-syntax-check}}
genmeblog commented 3 years ago

It's in Parboiled which is almost not maintained unfortunately. Same as Pegdown. This means that codox can be unusable on JDK 16+ (I have the same issue on 17).

frenchy64 commented 3 years ago

Workaround for Leiningen and deps.edn:

:jvm-opts ["--add-opens" "java.base/java.lang=ALL-UNNAMED"]
brunchboy commented 2 years ago

I ran into this same problem when one of my users was trying to build Afterglow under Java 17. I am glad there is at least a workaround for now.

weavejester commented 2 years ago

This should be fixed in 0.10.8.

brunchboy commented 2 years ago

Oh, thank you! I forgot that my plugins were not showing up in lein ancient, and was just stewing over the fact that the workaround broke my CI for building the online version of the developer guide, because the java version on Netlify, which builds and hosts it, is too ancient to support the --add-opens option. Updating codox is a much better answer. 😄

bostonaholic commented 2 years ago

@brunchboy You can check outdated plugins with lein ancient :plugins or lein ancient :all.

brunchboy commented 2 years ago

Indeed, when I remember to. Thanks again, all is well now that I have updated everything.

cloojure commented 2 years ago

When in doubt, write a function! Here is my favorite:

function lanc() {  # Lein ANCient
  echo ""
  echo ""-----------------------------------------------------------------------------
  echo "project.clj:"
  echo ""
  lein ancient check           :all
  echo ""
  echo ""-----------------------------------------------------------------------------
  echo "profiles.clj:"
  echo ""
  lein ancient check-profiles  :all
  echo ""-----------------------------------------------------------------------------
  echo ""
}

with result


~/expr/demo > lanc

-----------------------------------------------------------------------------
project.clj:

[org.clojure/clojure "1.11.1"] is available but we use "1.11.0" (use :check-clojure to upgrade)
[com.jakemccrary/lein-test-refresh "0.25.0"] is available but we use "0.24.1"

-----------------------------------------------------------------------------
profiles.clj:

-- ~/.lein/profiles.clj
all artifacts are up-to-date.

-----------------------------------------------------------------------------```