Skip to content

Commit 275cf81

Browse files
committed
standalnoe jre
1 parent 87a445c commit 275cf81

File tree

1 file changed

+38
-64
lines changed

1 file changed

+38
-64
lines changed

.github/workflows/reproduce-issue-7.yml

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515

16-
- name: Set up Temurin JDK 8
16+
- name: Set up Temurin JDK 8 (JAVA_HOME will point here)
1717
uses: actions/setup-java@v4
1818
with:
1919
java-version: '8'
@@ -22,78 +22,52 @@ jobs:
2222
- name: Build jar
2323
run: mvn package -DskipTests -q
2424

25-
- name: Show preconditions
25+
- name: Download Temurin JRE-only archive (simulates Oracle standalone JRE)
2626
shell: pwsh
2727
run: |
28-
Write-Host "JAVA_HOME: $env:JAVA_HOME"
29-
Write-Host ""
30-
Write-Host "attach.dll locations:"
31-
Write-Host " jre\bin\attach.dll : $(Test-Path "$env:JAVA_HOME\jre\bin\attach.dll")"
32-
Write-Host " bin\attach.dll : $(Test-Path "$env:JAVA_HOME\bin\attach.dll")"
33-
Write-Host " lib\tools.jar : $(Test-Path "$env:JAVA_HOME\lib\tools.jar")"
34-
Write-Host ""
35-
Write-Host "JVM library paths:"
36-
java -XshowSettings:property -version 2>&1 | Select-String "library.path"
37-
Write-Host ""
38-
Write-Host "Expected:"
39-
Write-Host " jre\bin\attach.dll = True (attach.dll only in jre\bin, not jdk\bin)"
40-
Write-Host " bin\attach.dll = False (key condition: missing from java.library.path)"
41-
Write-Host " java.library.path = ...\bin (jdk\bin - where attach.dll is absent)"
42-
Write-Host " sun.boot.library.path = ...\jre\bin (where attach.dll actually lives)"
28+
$url = "<https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u442-b06/OpenJDK8U-jre_x64_windows_hotspot_8u442b06.zip>"
29+
Invoke-WebRequest -Uri $url -OutFile jre8.zip
30+
Expand-Archive jre8.zip -DestinationPath jre8
31+
$jreHome = (Get-ChildItem jre8 -Directory)[0].FullName
32+
echo "STANDALONE_JRE=$jreHome" >> $env:GITHUB_ENV
4333
44-
- name: Reproduce the error
34+
- name: Show preconditions
4535
shell: pwsh
46-
# Expected failure:
47-
# java.util.ServiceConfigurationError:
48-
# com.sun.tools.attach.spi.AttachProvider:
49-
# Provider sun.tools.attach.WindowsAttachProvider could not be instantiated
50-
#
51-
# Root cause:
52-
# AgentAttach creates URLClassLoader(cp, null) to load tools.jar.
53-
# WindowsAttachProvider has a static initializer: System.loadLibrary("attach").
54-
# When called from a class loaded by a non-bootstrap classloader,
55-
# System.loadLibrary searches java.library.path (jdk\bin) — not sun.boot.library.path (jre\bin).
56-
# Temurin JDK 8 only ships attach.dll in jre\bin, so the load fails with UnsatisfiedLinkError.
57-
# The SPI loader wraps that in ServiceConfigurationError("could not be instantiated").
58-
#
59-
# The "list" subcommand is enough to trigger it: VirtualMachine.list() calls
60-
# AttachProvider.providers() which triggers SPI loading of WindowsAttachProvider.
6136
run: |
62-
$jar = (Get-ChildItem target\extract-tls-secrets-*.jar)[0].FullName
63-
Write-Host "Jar: $jar"
37+
Write-Host "=== JDK (JAVA_HOME) ==="
38+
Write-Host "Path : $env:JAVA_HOME"
39+
Write-Host "tools.jar : $(Test-Path "$env:JAVA_HOME\lib\tools.jar")"
40+
Write-Host "attach.dll : $(Test-Path "$env:JAVA_HOME\jre\bin\attach.dll")"
6441
Write-Host ""
65-
Write-Host "Command: java -jar $jar list"
66-
Write-Host " (tools.jar is NOT on the classpath — this is the key condition)"
42+
Write-Host "=== Standalone JRE (on PATH in real-world scenario) ==="
43+
Write-Host "Path : $env:STANDALONE_JRE"
44+
Write-Host "attach.dll : $(Test-Path "$env:STANDALONE_JRE\bin\attach.dll")"
45+
Write-Host "tools.jar : $(Test-Path "$env:STANDALONE_JRE\lib\tools.jar")"
6746
Write-Host ""
68-
java -jar $jar list
69-
continue-on-error: true
70-
71-
check-jre:
72-
runs-on: windows-latest
47+
Write-Host "JVM library paths when launched from standalone JRE:"
48+
& "$env:STANDALONE_JRE\bin\java.exe" -XshowSettings:property -version 2>&1 |
49+
Select-String "library.path"
7350
74-
steps:
75-
- name: Download Temurin JRE-only archive (not the JDK)
51+
- name: Reproduce error
7652
shell: pwsh
53+
# Explicitly invoke the standalone JRE's java.exe (not the JDK's).
54+
# JAVA_HOME still points to the JDK so tools.jar is found and
55+
# the URLClassLoader path in AgentAttach is taken.
56+
# sun.boot.library.path is derived from the standalone JRE's jvm.dll
57+
# and points to a bin\ with no attach.dll -- causing UnsatisfiedLinkError
58+
# inside WindowsAttachProvider's static initializer, which the SPI loader
59+
# wraps into:
60+
# ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider:
61+
# Provider sun.tools.attach.WindowsAttachProvider could not be instantiated
7762
run: |
78-
$url = "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u442-b06/OpenJDK8U-jre_x64_windows_hotspot_8u442b06.zip"
79-
Write-Host "Downloading JRE-only zip (no JDK)..."
80-
Invoke-WebRequest -Uri $url -OutFile jre8.zip
81-
Expand-Archive jre8.zip -DestinationPath jre8
63+
$java = "$env:STANDALONE_JRE\bin\java.exe"
64+
$jar = (Get-ChildItem target\extract-tls-secrets-*.jar)[0].FullName
8265
83-
- name: Inspect JRE structure and check for attach.dll
84-
shell: pwsh
85-
run: |
86-
$jre = (Get-ChildItem jre8 -Directory)[0].FullName
87-
Write-Host "JRE root: $jre"
66+
Write-Host "java.exe : $java (standalone JRE - no attach.dll)"
67+
Write-Host "JAVA_HOME: $env:JAVA_HOME (JDK - has tools.jar)"
68+
Write-Host "jar : $jar"
8869
Write-Host ""
89-
Write-Host "Top-level directories:"
90-
Get-ChildItem $jre -Directory | Select-Object -ExpandProperty Name
91-
Write-Host ""
92-
Write-Host "DLLs in bin\:"
93-
Get-ChildItem "$jre\bin\*.dll" | Select-Object Name | Sort-Object Name
94-
Write-Host ""
95-
Write-Host "attach.dll present : $(Test-Path "$jre\bin\attach.dll")"
96-
Write-Host "tools.jar present : $(Test-Path "$jre\lib\tools.jar")"
97-
Write-Host ""
98-
Write-Host "JVM library paths when running this JRE:"
99-
& "$jre\bin\java.exe" -XshowSettings:property -version 2>&1 | Select-String "library.path"
70+
Write-Host "Running..."
71+
& $java -jar $jar list
72+
continue-on-error: true
73+

0 commit comments

Comments
 (0)