I’m not familiar with Rosetta Code, but the example projects may indeed not 
have been updated for the latest JVM versions. Or maybe they use dependencies 
which haven’t been updated to get rid of these warnings when running on the JVM 
version you use with them, so they can’t be updated yet until those 
dependencies have been updated.

You can check the default JVM by running ‘echo $JAVA_HOME’. You can run ‘java 
-version’ to see its version.

Run ‘/usr/libexec/java_home -V’ to see all installed JVMs on your system. You 
can set JAVA_HOME to any of the JVM directories listed by that tool.

I personally use jEnv (’sudo port install jenv’) to specify which JVM I want to 
use for each of my projects when I run them from a terminal. See 
https://www.jenv.be/ for more information on how to set that up.

When you run projects from an IDE, you can typically tell the IDE which JVM to 
use for a particular project.

As these are ‘just warnings’ at this point, things should just work, but as the 
warning descriptions explain, things may break when run on future JVM feature 
versions.

Nils.

> Op 21 aug 2025, om 00:20 heeft Kenneth Wolcott <[email protected]> het 
> volgende geschreven:
> 
> Hi Nils;
> 
>  All my Kotlin experience is from experimenting with Kotlin code
> examples found on Rosetta Code.
> 
>  The same is true for Scala.
> 
>  My Java comes from MacPorts; I've got several versions, almost all
> of them quite recent; it's a guess for me which one to have active :-)
> 
>  I didn't neccessarily think that MacPorts ports were at fault :-)
> just curious...
> 
>  Are the Kotlin examples on Rosetta Code potentially all using
> deprecated Kotlin features?  I'm not seeing anything other than the
> warnings I mentioned here.
> 
> Thanks,
> Ken Wolcott
> 
> Thanks,
> Ken
> 
> On Wed, Aug 20, 2025 at 3:13 PM Nils Breunese <[email protected]> wrote:
>> 
>> Kenneth Wolcott <[email protected]> wrote:
>> 
>>> My Kotlin and Scala come from MacPorts.  My Kotlin (etc) ports are 
>>> up-to-date.
>>> 
>>> The following is something that I receive every time that I run Kotlin
>>> or Scala (or anything else that depends on a JVM):
>>> 
>>> WARNING: A restricted method in java.lang.System has been called
>>> WARNING: java.lang.System::load has been called by
>>> org.fusesource.jansi.internal.JansiLoader in an unnamed module
>>> WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for
>>> callers in this module
>>> WARNING: Restricted methods will be blocked in a future release unless
>>> native access is enabled
>>> 
>>> WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
>>> WARNING: sun.misc.Unsafe::objectFieldOffset has been called by
>>> com.intellij.util.containers.Unsafe
>>> WARNING: Please consider reporting this to the maintainers of class
>>> com.intellij.util.containers.Unsafe
>>> WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future 
>>> release
>>> 
>>> What is the appropriate action for me, as an end user, to take?
>> 
>> It looks like the combination of the JVM version you use and the code you’re 
>> executing causes these warnings. These seem like software-specific warnings, 
>> not general warnings that would appear for anything that runs on a JVM. I 
>> don’t see these warnings when I run my own software for instance.
>> 
>> Both warnings are about compatibility problems with future JVM versions. The 
>> warnings tell you what you could do.
>> 
>> The first warning says that org.fusesource.jansi.internal.JansiLoader calls 
>> the java.lang.System::load method, and that that is a restricted method that 
>> will be blocked in a future JVM release unless native access is enabled, 
>> which you can do by running the JVM with the 
>> --enable-native-access=ALL-UNNAMED flag. How you can specify this flag 
>> depends on how the software you’re running is executed. You could try set 
>> the JDK_JAVA_OPTIONS environment variable with this flag for the command you 
>> run, or pass the flag directly to the ‘java’ command if you run the software 
>> like that. Alternatively an update of this software may be available which 
>> doesn’t require fixing this yourself. Or you could choose to ignore this 
>> warning for now, or run this software on an older JVM version which doesn’t 
>> result in this warning.
>> 
>> The second warning says that com.intellij.util.containers.Unsafe calls 
>> sun.misc.Unsafe::objectFieldOffset, which will be removed in a future JVM 
>> release. You could ignore the warning for now, see if there is an update of 
>> this software which doesn’t use this deprecated method, or run this software 
>> on an older JVM version which doesn’t result in this warning.
>> 
>> What is the software you’re running when you see these warnings? Is this 
>> software provided by MacPorts? If not, this is not really anything that can 
>> be ‘fixed’ in MacPorts.
>> 
>> Also, which JVM do you use for running these programs? (The default JVM is 
>> typically set via the JAVA_HOME environment variable when not set explicitly 
>> for a specific execution.) The software you run may be targeting older Java 
>> versions, and may not be adjusted for the upcoming changes in future Java 
>> versions, which is why you’re seeing these warnings.
>> 
>> Nils.

Reply via email to