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

Fix VerifyError on some environments #1

Merged
merged 1 commit into from
Aug 16, 2020
Merged

Fix VerifyError on some environments #1

merged 1 commit into from
Aug 16, 2020

Conversation

athos
Copy link
Owner

@athos athos commented Aug 16, 2020

When I load pogonos.reader in the Clojure CLI REPL on JVM 14, I run into a VerifyError like the following:

$ clj
Clojure 1.10.1
user=> (require 'pogonos.reader)
Syntax error (VerifyError) compiling new at (pogonos/reader.cljc:36:4).
Operand stack underflow
Exception Details:
  Location:
    pogonos/reader/FileReader.close()Ljava/lang/Object; @6: areturn
  Reason:
    Attempt to pop empty stack.
  Current Frame:
    bci: @6
    flags: { }
    locals: { 'pogonos/reader/FileReader' }
    stack: { }
  Bytecode:
    0x0000000: 2ab9 0090 0100 b0

user=>

The same goes for Clojure CLI on JVM 8 and lein repl on JVM 14, but NOT for lein repl on JVM 8.

I'm not really sure what is exactly causing this (maybe the difference of classloaders and/or some change in the bytecode verification logic matters?), but after digging into it for a while, I figured out this happens if the reader impls implement java.io.Closeable#close() (which overloads pogonos.protocols/IReader#close()).

My first design decision for making the readers implement java.io.Closeable was just for the user's convenience. Now, however, I don't think It's worthwhile to do so because:

  • In most cases, we, as a user, don't need to handle the readers directly
  • Even when we really do, we can use pogonos.protocols/IReader#close() instead of java.io.Closeable#close()

So, this PR removes the java.io.Closeable implementation from the readers to work around the VerifyError. This really is a breaking change, but its impact won't be so significant for the reasons above.

@codecov
Copy link

codecov bot commented Aug 16, 2020

Codecov Report

Merging #1 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #1   +/-   ##
=======================================
  Coverage   90.25%   90.25%           
=======================================
  Files          10       10           
  Lines         718      718           
  Branches       39       39           
=======================================
  Hits          648      648           
  Misses         31       31           
  Partials       39       39           
Impacted Files Coverage Δ
src/pogonos/core.cljc 85.71% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1ba9e4...fa337e1. Read the comment docs.

@athos athos merged commit e8905f7 into master Aug 16, 2020
@athos athos deleted the fix/verify-error branch August 16, 2020 08:38
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

Successfully merging this pull request may close these issues.

1 participant