Skip to content

do not expose Java proxy generated classes in Ruby land#8350

Closed
kares wants to merge 4 commits intojruby:masterfrom
kares:proxy-class-init
Closed

do not expose Java proxy generated classes in Ruby land#8350
kares wants to merge 4 commits intojruby:masterfrom
kares:proxy-class-init

Conversation

@kares
Copy link
Member

@kares kares commented Sep 16, 2024

this PR changes some of the bits from: 31f1ed6

e.g. it effectively makes sure getProxyClass (which might be used in user ext) behaves as before - not setting a Java proxy class constant upon every invocation...

fixes #8349

@kares
Copy link
Member Author

kares commented Sep 17, 2024

right, so this is turning out to be a mess - current approach is not sufficient and we basically restore more of 31f1ed6 to get proxy class initialization ~ in 9.4.6.0

first, the #8208 causes the proxy class to be assigned multiple times (it's just that the warnings do not surface in CI much and JRuby also has checks to ignore them due potential concurrent loading e.g. #8250)

second, I am not sure the fix for #8156 is legit, internally both proxy classes will be present it's just a question which one will "surface" first.

@headius
Copy link
Member

headius commented Sep 18, 2024

@kares The main problem here is just the proxy classes getting into the constant table, right? Can't we just avoid that aspect and leave the rest the way it is? Store it some other way?

@kares
Copy link
Member Author

kares commented Sep 22, 2024

the thing I do not like is we're now constantly doing the checking of the proxy constant on every getProxyClass path, previously the setting of the constant only happened on paths that mostly executed once (e.g. on method_missing).

the current way I could think of (wout bigger refactoring) would be to revert 31f1ed6 and try implementing it without changing getProxyClass... unless you have a better idea I would try that (current state of PR here is not the way to go).

@headius
Copy link
Member

headius commented Sep 24, 2024

unless you have a better idea I would try that

@kares Yeah go ahead and try something else. I was hopeful that that simple fix would be safe, but it seems there's this side effect we definitely don't want.

The original issue was that a random generated version of a class was added into that global namespace, masking the one that lives in JRuby's classloader hierarchy. If we can solve that in a more targeted way (comparing classloader hierarchy? some fast way to check if this class was loaded from our classloaders?) I'd be thrilled.

@kares
Copy link
Member Author

kares commented Oct 10, 2024

second attempt at #8368

@kares kares closed this Oct 10, 2024
@enebo enebo added this to the Invalid or Duplicate milestone Nov 4, 2024
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.

internal proxy class is stored in Ruby land and prints warning

3 participants