Access ARG between stages in Dockerfile

I am not interested in keeping the JDK11 beyond building the image.
I need the JAVA_HOME from the jdk11 image as an argument within the build process.

It is needed for the path of the Java installation I am using in the COPY statement.

I found an explanation on Docker GitHub that might explain what I want is not possible.

Basically, after the FROM instruction all the build arguments are reset and thus aren’t available in the Dockerfile.

Anyone have an idea how I can work around this?

I need the JAVA_HOME environment variable taken in FROM jdk11 into the FROM base.

Would ENV work instead for what I am trying to do.