Skip to content

Conversation

@palfrey
Copy link
Contributor

@palfrey palfrey commented Oct 31, 2017

This PR enables "*warn-on-reflection*" and fixes all the reflection warnings I found as a result. I've run the test suite locally, and haven't hit any issues, but there could potentially still be regression issues if someone's calling something with a class I haven't hit during my testing.

@palfrey
Copy link
Contributor Author

palfrey commented Oct 31, 2017

Well, technically, not all of them. I can't fix one in nonce.clj (buddy/core/nonce.clj:49:6 - call to method put on java.nio.ByteBuffer can't be resolved (argument types: java.lang.Object)) but that only seems to occur in the Clojure 1.7 setup of test-all, and I've added in what should be appropriate hinting for that anyways.


(def ^:no-doc
+block-cipher-engines+
^BlockCipher +block-cipher-engines+
Copy link
Member

Choose a reason for hiding this comment

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

I think that this type hint is wrong, because +block-cipher-engines+ is a hash-map and not a BlockCipher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed


(def ^:no-doc
+cipher-modes+
^BlockCipher +cipher-modes+
Copy link
Member

Choose a reason for hiding this comment

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

The same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@palfrey
Copy link
Contributor Author

palfrey commented Dec 10, 2017

I'm slightly worried about the BlockCipher hints not causing any test failures...

@kwojcik-blockether
Copy link

@niwinz It seems legit for me. Just tested the changes and checked them all. It seems that it's working just fine

@harold
Copy link

harold commented Apr 28, 2020

Hi - 👋 - we've adopted buddy-hashers to do some password hashing, and it and this library are great. Appreciate everyone's efforts here.

These reflection warnings bubble up into our tools, so I dove in to investigate and fix them up and then found this excellent branch. Is there any interest in trying to merge this branch, or one like it but cleanly rebased off current master? I'd be happy to do the work.

@palfrey
Copy link
Contributor Author

palfrey commented Apr 28, 2020

Just merged master and all was fine. Travis appears to have built cleanly (https://travis-ci.org/github/funcool/buddy-core/builds/680771704) but something is wrong with the feedback to this PR.

@harold
Copy link

harold commented Apr 28, 2020

Cool - great work.

I completely understand being careful about changes to this particular piece of machinery.

We are here and have some spare cycles if there's anything we can do to push this forward - let me know.

@niwinz
Copy link
Member

niwinz commented Dec 3, 2020

Finally merged! thanks!

@palfrey palfrey deleted the reflection-fixes branch December 3, 2020 10:38
@harold
Copy link

harold commented Dec 3, 2020

Nice! Thanks, yous. 👏 🙇

@palfrey
Copy link
Contributor Author

palfrey commented Dec 3, 2020

I note there are now other warnings as the set of checked items are out of date. Also, it's a warning, not an error so it doesn't fail the build, so harder due people to notice the issue.

@harold
Copy link

harold commented Dec 4, 2020

This is what I see now, are you seeing the same?

$ lein check Compiling namespace buddy.core.bytes Compiling namespace buddy.core.certificates Compiling namespace buddy.core.codecs Compiling namespace buddy.core.codecs.base64 Compiling namespace buddy.core.crypto Compiling namespace buddy.core.dsa Compiling namespace buddy.core.hash Compiling namespace buddy.core.kdf Compiling namespace buddy.core.keys Reflection warning, buddy/core/keys/jwk/eddsa.clj:31:19 - reference to field getDeclaredConstructors can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:33:37 - reference to field getParameterCount can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:34:64 - reference to field getParameterTypes can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:34:58 - call to static method aget on clojure.lang.RT can't be resolved (argument types: unknown, int). Reflection warning, buddy/core/keys/jwk/eddsa.clj:38:5 - call to method setAccessible can't be resolved (target class is unknown). Reflection warning, buddy/core/keys/jwk/eddsa.clj:39:5 - call to method newInstance can't be resolved (target class is unknown). Reflection warning, buddy/core/keys/jwk/eddsa.clj:46:5 - call to static method copyOfRange on java.util.Arrays can't be resolved (argument types: unknown, long, java.lang.Number). Reflection warning, buddy/core/keys/jwk/eddsa.clj:50:3 - call to static method copyOfRange on java.util.Arrays can't be resolved (argument types: unknown, long, java.lang.Number). Reflection warning, buddy/core/keys/jwk/eddsa.clj:77:17 - reference to field getEncoded can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:78:22 - reference to field getPublicKey can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:78:43 - reference to field getEncoded can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:79:15 - call to static method equals on java.util.Arrays can't be resolved (argument types: unknown, unknown). Compiling namespace buddy.core.keys.jwk.ec Compiling namespace buddy.core.keys.jwk.eddsa Reflection warning, buddy/core/keys/jwk/eddsa.clj:31:19 - reference to field getDeclaredConstructors can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:33:37 - reference to field getParameterCount can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:34:64 - reference to field getParameterTypes can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:34:58 - call to static method aget on clojure.lang.RT can't be resolved (argument types: unknown, int). Reflection warning, buddy/core/keys/jwk/eddsa.clj:38:5 - call to method setAccessible can't be resolved (target class is unknown). Reflection warning, buddy/core/keys/jwk/eddsa.clj:39:5 - call to method newInstance can't be resolved (target class is unknown). Reflection warning, buddy/core/keys/jwk/eddsa.clj:46:5 - call to static method copyOfRange on java.util.Arrays can't be resolved (argument types: unknown, long, java.lang.Number). Reflection warning, buddy/core/keys/jwk/eddsa.clj:50:3 - call to static method copyOfRange on java.util.Arrays can't be resolved (argument types: unknown, long, java.lang.Number). Reflection warning, buddy/core/keys/jwk/eddsa.clj:77:17 - reference to field getEncoded can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:78:22 - reference to field getPublicKey can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:78:43 - reference to field getEncoded can't be resolved. Reflection warning, buddy/core/keys/jwk/eddsa.clj:79:15 - call to static method equals on java.util.Arrays can't be resolved (argument types: unknown, unknown). Compiling namespace buddy.core.keys.jwk.okp Compiling namespace buddy.core.keys.jwk.proto Compiling namespace buddy.core.keys.jwk.rsa Compiling namespace buddy.core.keys.pem Compiling namespace buddy.core.mac Compiling namespace buddy.core.nonce Compiling namespace buddy.core.padding Compiling namespace buddy.util.deflate Compiling namespace buddy.util.ecdsa 
@palfrey palfrey restored the reflection-fixes branch December 4, 2020 22:23
@palfrey palfrey deleted the reflection-fixes branch December 4, 2020 22:23
@palfrey
Copy link
Contributor Author

palfrey commented Dec 5, 2020

This is what I see now, are you seeing the same?

Hadn't re-run it locally, was just looking at the Travis builds e.g https://travis-ci.org/github/funcool/buddy-core/jobs/747388146 but that looks about the same, plus some issues in the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants