#testing both jdk8 and jdk16+ in same IJ project

1 messages · Page 1 of 1 (latest)

cold island
#

I mistakenly started a project in java 17, and now have updated things to be compatible with java 8, I've updated all the project/module settings I could find, yet its still running in java 17. However when I check maven settings it says its using java 17, and i've also updated my pom to be java 8. Im not sure why it thinks the project is still java 8

I can share my screen in VC needed

pure ruinBOT
#

<@&987246527741304832> please have a look, thanks.

cold island
#

the only other weirdness ic an find is misc.xml has java <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-1.8 (2)" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> i tried setting it to JDK_8 and it didnt work and auto updated itself back to 17

#

yeah im not sure how this one mappened... anyone know how to fix this "1.8 (2)" issue or how it pulls the sdk options

bronze drum
#

Have you tried reimporting your Maven project?

cold island
#

ah platform settings SDKs

#

yeah i tried that, i think fixing my platform settings will fix it tho, fixing some dead jdk paths

#

W. I have no clue how i got jdk 17 path in the 1.8 labeled sdk lol. wonder how long thats been broken

#

also i guess the next thing i need to figure out how to test with this is to have 2 /test folders, one for jdk8 and one for jdk16 (records)

pure ruinBOT
#

testing both jdk8 and jdk16+ in same IJ project

#

Changed the title to testing both jdk8 and jdk16+ in same IJ project.

bronze drum
cold island
#

oh i guess i can try that i didnt know those existed

#

but will it conditionally compile record classes?

bronze drum
#

Alternatively different build profiles.

rose wedge
#

show your POM

cold island
rose wedge
#

Java 9 introduced breaking changes. if it doesnt work, you may be depending on one of those breaking changes

bronze drum
rose wedge
#

trying to run a Java 8 app on a Java 23 runtime aint easy

cold island
#

i know of openrewrite but what im trying to do is write a simple library (similar to jackson databind) that supports both records and classes on java 8+. From some manual testing it looks like i have it working (not committed to the repo) but idk if I can have a nice way of easily testing different versions without just changing my junit run config and maybe commenting stuff out

bronze drum
rose wedge
#

the Java 8 compiler doesnt support records

#

it doesnt make sense

cold island
#

yeah but I can reflectively get record data from the runtime after checking for java.lang.Record, so the code itself isnt the problem, testing is

rose wedge
#

that was introduced in 16 though

#

java.lang.Record

cold island
#

e.g. compile in java 8, add dependency to java 16+ project, should work

rose wedge
#

does it? i havent tested anything like that before

#

programming in a Java 8 environment, running on modern Java (like 23), and simply adding a higher version to access the standard lib of a higher version

#

that's a wild situation

cold island
#

technically I can access RecordComponent via reflection but it seems like getDeclaredFields is working well enough that I dont need to check any specific record-types' reflection methods

livid elm
#

I woudl suggest deleting and re-adding SDKs

fallow raft
cold island
cold island
#

why not 🤷‍♀️

#

the only thing thats painful is not having var with reflection t ypes

livid elm
#

I can't live without .formatted()

#

and it came with text blocks in 15

cold island
#

OpenRewrite changing String.format to .formatted by default really grinds my gears

livid elm
#

it's superior

fallow raft
# cold island why not 🤷‍♀️

Because it's old, it's not longer supported, it has less features and you have trouble to make your program works with it ???
The question isn't why not using java 8, but why not using latest, the default is to use latest
You need a good reason to use an old version of java, not the opposite

cold island
#

its a library project though not an application

fallow raft
#

ah

leaden surge
#

<name>${project.groupId}:${project.artifactId}</name>

#

well thats a nightmare

leaden surge
cold island
#

Thats not the artifact name tho is it? Maybe the build name? Either way i've not had any problems with it cause the artifact name is still better-env and the full artifact id has the :

#

But like I mainly made it for myself to use in some CLI runner projects to avoid all the manual null checking and error logging
So i prob could have made it on java16 but the cost was low to compile on with java 8

leaden surge
cold island
#

Im typically on lts 21 until 25 drops, but id rather have the portability and not need it