Skip to content

Refactor - adding different scala object detecting#656

Open
marcinbelicki wants to merge 10 commits intoFasterXML:2.17from
marcinbelicki:refactor/adding-different-scala-object-detecting
Open

Refactor - adding different scala object detecting#656
marcinbelicki wants to merge 10 commits intoFasterXML:2.17from
marcinbelicki:refactor/adding-different-scala-object-detecting

Conversation

@marcinbelicki
Copy link
Copy Markdown

@marcinbelicki marcinbelicki commented Nov 30, 2023

I'm adding ScalaObject along with ScalaObjectTest to detect whether given Class[_] is a scala singleton object. I'm not sure if clazz can be a null but I'm adding Option(clazz) in ScalaObjectDeserializerResolver just in case.


case object TestCaseObject

class TestClass
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not add to src/test/scala ? does this not work with scala 3?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it the classes with names ending in $ - maybe scala3 doesn't allow this?

It is weird to have classes ending in $ - is there any way not to use these in tests?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think these are not necessary in tests but they are used just to make sure ScalaObject.unapply do not detect classes with names that end with a $ as scala singleton objects

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These class names are probably legal in scala 2 but illegal in scala 3. Since I haven't seen anyone in their right mind to use such class names I'm deleting them.

@pjfanning
Copy link
Copy Markdown
Member

build fails with

[info] com.fasterxml.jackson.module.scala.ScalaObjectMapperTest *** ABORTED ***
[info]   java.lang.InternalError: Malformed class name
[info]   at java.lang.Class.getSimpleName(Class.java:1330)
[info]   at com.fasterxml.jackson.module.scala.util.ScalaObject$.unapply(ScalaObject.scala:27)

@marcinbelicki
Copy link
Copy Markdown
Author

I've corrected clazz.getSimpleName to clazz.getName - I wasn't aware that classes from inside of scala singleton objects cant produce propper simple name :/

@pjfanning
Copy link
Copy Markdown
Member

@marcinbelicki I've started #657 - I may grab more of the changes in this PR but there I don't like all the new classes in this PR

@marcinbelicki
Copy link
Copy Markdown
Author

Ok, I see your point

@pjfanning
Copy link
Copy Markdown
Member

@marcinbelicki #657 is merged and will appear in v2.16.1 release - thanks for driving this

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.

2 participants