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.util.jar.Attributes to classes #1463

Closed
jeroenvandijk opened this issue Jan 11, 2023 · 1 comment
Closed

Add java.util.jar.Attributes to classes #1463

jeroenvandijk opened this issue Jan 11, 2023 · 1 comment

Comments

@jeroenvandijk
Copy link
Contributor

jeroenvandijk commented Jan 11, 2023

Is your feature request related to a problem? Please describe.

I'm trying to the get Main-Class attribute from a Jar file, specifically for this issue in bbin (babashka/bbin#47) The class java.util.jar.Attributes and specifically the method java.util.jar.Attributes/getValue seems to be missing
in the classes list

Describe the solution you'd like
Adding the class to the list

Describe alternatives you've considered
The workaround is to iterate over the attributes and parse the key of the attributes for "Main-Class", see the code here

Additional context
babashka/bbin#47

Some code to see this problem in action

bb version
babashka v1.0.164

bb -e '(let [clojure-jar-path (str (System/getenv "HOME") "/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0.jar")
      jar-file (clojure.java.io/file clojure-jar-path)]
  (with-open [jar (java.util.jar.JarFile. jar-file)]
    (-> (java.net.URL. "jar" nil (str "file:" (.getAbsolutePath jar-file) "!/META-INF/MANIFEST.MF"))
        (clojure.java.io/input-stream)
        (java.util.jar.Manifest.)
        (.getMainAttributes)
        (.getValue "Main-Class"))))'
----- Error --------------------------------------------------------------------
Type:     java.lang.IllegalArgumentException
Message:  No matching method getValue found taking 1 args for class java.util.jar.Attributes
Location: <expr>:1:1

----- Context ------------------------------------------------------------------
1: (let [clojure-jar-path (str (System/getenv "HOME") "/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0.jar")
   ^--- No matching method getValue found taking 1 args for class java.util.jar.Attributes
2:       jar-file (clojure.java.io/file clojure-jar-path)]
3:   (with-open [jar (java.util.jar.JarFile. jar-file)]
4:     (-> (java.net.URL. "jar" nil (str "file:" (.getAbsolutePath jar-file) "!/META-INF/MANIFEST.MF"))
5:         (clojure.java.io/input-stream)
6:         (java.util.jar.Manifest.)
@borkdude
Copy link
Collaborator

PR welcome

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