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

[Famix-Java] mooseNameOn: on Java inner class does not include $ #650

Closed
alkalinan opened this issue Nov 30, 2023 · 0 comments
Closed

[Famix-Java] mooseNameOn: on Java inner class does not include $ #650

alkalinan opened this issue Nov 30, 2023 · 0 comments

Comments

@alkalinan
Copy link

alkalinan commented Nov 30, 2023

problem description

In Java, the full qualify name of a class includes an $ symbol in front of inner java class name. Consequently, when comparing a method signature from the JVM with signature generated from a Famix Moose java model (e.g. with mooseNameWithDots); the two signatures do not match.

"example: "
model := MooseModel root first.
inner := (model allModelClasses detect: #isInnerClass).
inner  mooseNameWithDots
"'fr.magnus.ucbondecommande.ihmintranet.fiche.OngletIdentification.AchatGrilleListener'"

"instead of (from Java)"
"'fr.magnus.ucbondecommande.ihmintranet.fiche.OngletIdentification$AchatGrilleListener'"

proposed solution

my solution is 'hacky', because moose name are store in cache, I've changed the method mooseNameWithDots and mooseNameOn

mooseNameWithDots

	self resetMooseName.
	^ self mooseName ifNotNil: [ '.' join: (self mooseName substrings: '::') ].

The 'hack' is to resetMooseName each time to be sure that it is now store properly.

FamixTType::FamixJavaClass::mooseNameOn: aStream

	self typeContainer
		ifNotNil: [ :parent |
			|separator|
			separator := '::'.
			self isInnerClass ifTrue: [ separator := '$' ].
			parent mooseNameOn: aStream.
			aStream nextPutAll: separator  ].
	self name ifNotNil: [ :n | aStream nextPutAll: n ]

This solution works but may causes compatibility issues.

(my first famix issue 🤓 )

LABSARI added a commit that referenced this issue Mar 29, 2024
…On-on-Java-inner-class-does-not-include-

Fix #650
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