0

I've got Java code that is subclassing com.sun.javafx.scene.control.skin.TextFieldSkin. (Yes, I know that I'm supposed to beware using sun.com.*.) Consider me appropriately chastized.

With Java 9, this class is now in the mainstream, available as javafx.scene.control.skin.TextFieldSkin. I'd like my code to be buildable on Java 8 and higher. But since the code has moved, I need different imports depending on the version.

I can't do conditional inheritance based on Java version, because it happens at compile time. I'm using Maven, so I could use the Munge plugin to do conditional compilation; that appears as though it will work, though it will cause annoying errors to be flagged in my development environment in realtime as I code because the import in either case will be enclosed in comments away.

What's the right way to handle this?

Vultan
  • 409
  • 3
  • 13
  • if you are using ant you could have different build files per version and scripts to "compensate" for the changes – Tschallacka Aug 07 '18 at 15:56
  • 1
    Just move problematic parts to 2 different maven modules and put them in profiles activated based on jdk version – rkosegi Aug 07 '18 at 16:19
  • Thanks, @rkosegi. I'll give it a try. – Vultan Aug 10 '18 at 16:22
  • for instance team developing postgres jdbc uses java preprocessor to build variants for different classes, also it is possible to use java preprocessor to build applications for jep-238 https://github.com/raydac/jep-238-jcp-example – Igor Maznitsa Feb 01 '19 at 06:51

0 Answers0