Skip to content
Advertisement

Jackson polymorphic serialization generates an incorrect class name

When I use Jackson polymorphic serialization, it generates a JSON object with an incorrect fully qualified class name. The code below serializes an XMLGregorianCalendar. The output is: I expected the following: Why does it output java.util.GregorianCalendar? Or more importantly: How do I fix this? Code example: Answer To get the expected behavior I have implemented a custom XMLGregorianCalendar serializer. This

confusion about upcasting vs dynamic binding

So I am having some confusion understanding dynamic binding vs upcasting. My original understanding was that when you create a base_class reference and assign it to a derived class object like: you can now call the methods/member functions of derived_class with obj.method_of_derived class(), without dynamic binding. I thought you only needed dynamic binding when the base_class and derived_class have functions/methods

Is there anyway to get the size of the text in a JTextArea?

The title pretty much says it all. What I don’t mean is how to get the size of the JTextArea. I need to get the size of the actual text. I am completely open to suggestions though. If you have a wonky workaround that involves using something other than JTextArea but still has a similar effect, I’d love to hear

401 instead of 403 with Spring Boot 2

With Spring Boot 1.5.6.RELEASE I was able to send HTTP Status code 401 instead of 403 as described in How let spring security response unauthorized(http 401 code) if requesting uri without authentication, by doing this: using the org.springframework.boot.autoconfigure.security.Http401AuthenticationEntryPoint class. I just upgraded to Spring Boot 2.0.0.RELEASE and found there is not such class any more (at least in that package).

this pointer escape in Java

When reading < Java Concurrency in Practice >, there’s an example saying that the following code snippet will lead to this pointer escape in the constructor method. But I’m not sure what exactly does it mean, since I couldn’t see any this reference in the source code of ThisEscape constructor method. Any ideas? Thanks. Answer EventListener object is created from

How can I mask a hexadecimal int using Java?

I have an integer that contains a hexa value. I want to extract the first characters from this hexa value like it was a String value but I don’t want to convert it to a String. In my case I can’t use String utilities like substring. Answer It’s important to understand that an integer is just a number. There’s no

disable-infobars argument unable to hide the infobar with the message “Chrome is being controlled by automated test software” with ChromeDriver v2.36

I just updated ChromeDriver to newest version – 2.36. In previous versions I’ve set: and the “Chrome is being controlled by automated test software” warning bar wasn’t displayed. With the same option set, I’m keep seeing it. Do you know how to disable this from appearing in the newest ChromeDriver? Thanks in advance Answer New version of ChromeDriver has been

Advertisement