Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openjdk-21: java can t use Runtime.exec #21225

Closed
dev-mz opened this issue Aug 23, 2024 · 1 comment
Closed

openjdk-21: java can t use Runtime.exec #21225

dev-mz opened this issue Aug 23, 2024 · 1 comment
Labels
bug report Something is not working properly

Comments

@dev-mz
Copy link

dev-mz commented Aug 23, 2024

Problem description

For Android, posix_spawn fixed subprocess args first element equal to program path, when jdk call jspawnhelper, the first will override by the path then will be the issue.
pls check this commit openjdk/mobile@47d00a4

What steps will reproduce the bug?

import java.io.IOException;
import java.io.File;

public class Main {
	final static String test = "/system/bin/ls";
	final static String workdir = "/data/data/com.termux/files/home";
	public static void main(String[] args) {
		final File dir = new File(workdir);
		final ProcessBuilder pb = new ProcessBuilder(new String[]{test});
		pb.directory(dir);
		try {
			final Process p = pb.start();
			System.out.println(p.waitFor());
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
This command is not for general use and should only be run as the result of a call to
ProcessBuilder.start() or Runtime.exec() in a java application
java.io.IOException: Cannot run program "/system/bin/ls" (in directory "/data/data/com.termux/files/home"): error=0,
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089)
        at Main.main(Main.java:12)
Caused by: java.io.IOException: error=0,
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:295)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:225)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1126)
        ... 2 more

What is the expected behavior?

list home files.

System information

no need
@dev-mz dev-mz added bug report Something is not working properly untriaged labels Aug 23, 2024
@licy183
Copy link
Member

licy183 commented Aug 24, 2024

openjdk-21 hasn't been packaged by Termux main repository. There is a WIP PR #20793

@licy183 licy183 removed the untriaged label Aug 24, 2024
@dev-mz dev-mz closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

2 participants