Skip to content

Conversation

@laurit
Copy link
Contributor

@laurit laurit commented Oct 22, 2025

No description provided.

-PtestJavaVersion=${{ matrix.test-java-version }}
-PtestJavaVM=${{ matrix.vm }}
-PtestIndy=${{ matrix.test-indy }}
-PdenyUnsafe=${{ matrix.test-java-version >= 23 && 'true' || 'false' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run jdk25 tests with unsafe disabled to verify that everything works. I guess it is an open question whether we want to test without unsafe at all at this point or whether we want to do it in some other way as running with unsafe requires disabling tests that use unsafe.

import java.util.function.Supplier;

/**
* Helper class that provides a MethodHandles.Lookup that allows defining classes in this package.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be needed with indy advice that would define helper classes in a separate class loader. With inline advice this class provides access to a lookup that lets us define classes in the package used by the executors instrumentation.

* jdk.internal.misc.Unsafe. Used when jdk provided sun.misc.Unsafe is not available which can
* happen when running modular application without jdk.unsupported module.
*/
class SunMiscUnsafeGenerator {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a modular application was run without jdk.unsupported module we generate a copy of sun.misc.Unsafe that delegated to jdk.internal.misc.Unsafe. Since we don't rely on sun.misc.Unsafe any more we don't need this.

private void injectBootstrapClassLoader(Map<String, Supplier<byte[]>> inject) throws IOException {
static {
// add lookups for instrumentations that define classes in boot loader
addPackageLookup(new ExecutorLookupSupplier());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing lookup that can define classes in these packages isn't strictly necessary because there is a fallback to ClassInjector.UsingInstrumentation. While ClassInjector.UsingInstrumentation works it requires packaging classes to a jar and using Instrumentation.appendToBootstrapClassLoaderSearch. Apparently every time that method is called

OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

is printed, which is a minor annoyance. Another potential issue, which I didn't verify, is that on windows the jars that are appended to boot loader can't probably be deleted, at least not right away. We might need to check whether this is true or whether they are deleted only on exit. Could also depend on the vm version.

@laurit laurit marked this pull request as ready for review October 24, 2025 14:24
@laurit laurit requested a review from a team as a code owner October 24, 2025 14:24
Comment on lines +34 to +35
// in the constructor of DefaultStreamMessage replace new MpscChunkedArrayQueue with new
// ConcurrentLinkedQueue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂❤️

Comment on lines +38 to +39
// using a system property here will enable the instrumentation when declarative config is used
return Boolean.getBoolean("otel.instrumentation.deny-unsafe.enabled");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants