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

reflections saves serialized data in wrong directory if full path contains dots #478

Open
NHOrus opened this issue Feb 20, 2025 · 2 comments

Comments

@NHOrus
Copy link

NHOrus commented Feb 20, 2025

String filename = name.replace('.', '/').concat(".java");

so, e.g. if it tries to save reflection data of org.reflections.MyTestModelStore to
/var/tmp/portage/dev-java/reflections-0.9.16-r6/work/reflections-0.9.16/src/test/java/org/reflections/MyTestModelStore.java
it would instead save it to
/var/tmp/portage/dev-java/reflections-0/9/12-r6/work/reflections-0/9/12/src/test/java/org/reflections/MyTestModelStore.java
which is incorrect.

Found in Gentoo:
https://bugs.gentoo.org/949232

@NHOrus
Copy link
Author

NHOrus commented Feb 20, 2025

Right solution would be something like:

File temporaryfile = File(name)
String temppath = temporaryfile.getParent()
String tempname = temporaryfile.getName().replace('.', File.separator).concat(".java")
String filename = temppath + File.separator + tempname

But I don't know java well

@NHOrus
Copy link
Author

NHOrus commented Feb 20, 2025

Elaborating: That line replaces all the dots in the path string with slashes, because it expects that only classname at the end of the name contains dots. Assumption that is proven incorrect when given absolute path with dots in it.

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

1 participant