gpt4 book ai didi

java - IDE 想要将我的 Int 转换为 boolean 值?我的方法之一说它不能应用

转载 作者:行者123 更新时间:2023-12-02 11:56:56 25 4
gpt4 key购买 nike

我遇到了问题。它想将 int len 更改为 boolean 值? addNode 方法存在一些问题。
不太确定还要添加什么,这个小盒子对我大喊要添加更多细节。我有所需的所有进口。

public class CustomClassLoader extends ClassLoader {


private HashMap<String, ClassNode> classes = new HashMap<String, ClassNode>();


@Override

public Class<?> loadClass(String name) throws ClassNotFoundException {

return findClass(name);

}


@Override

protected Class<?> findClass(String name) throws ClassNotFoundException {

ClassNode node = classes.get(name.replace('.', '/'));

if (node != null)

return nodeToClass(node);

else

return super.findClass(name);

}


public final void addNode(String name, ClassNode node) {

classes.put(node.name, node);

}


private final Class<?> nodeToClass(ClassNode node) {

if (super.findLoadedClass(node.name) != null)

return findLoadedClass(node.name);

ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);

node.accept(cw);

byte[] b = cw.toByteArray();

return defineClass(node.name.replace('/', '.'), b, 0, b.length,

getDomain());

}


private final ProtectionDomain getDomain() {

CodeSource code = new CodeSource(null, (Certificate[]) null);

return new ProtectionDomain(code, getPermissions());

}


private final Permissions getPermissions() {

Permissions permissions = new Permissions();

permissions.add(new AllPermission());

return permissions;

}
private HashMap<String,URL> resources = new HashMap<String,URL>();
public final void addResource(String name,URL url){

resources.put(name, url);

}
protected URL findResource(String name) {

if (getSystemResource(name) == null){

if (resources.containsKey(name))

return resources.get(name);

else

return null;

}else

return getSystemResource(name);

}

public void loadClassesFromJar(File jar) throws IOException {

ZipFile jf = new ZipFile(jar);

ZipEntry e;

Enumeration<? extends ZipEntry> entries = jf.entries();

while (entries.hasMoreElements()) {

e = entries.nextElement();

if(e.isDirectory())

continue; //skip directories, as the file names contain the slashes

InputStream in = jf.getInputStream(e);

if (e.getName().endsWith(".class")) {

// reads the class

ClassReader reader = new ClassReader(in);

ClassNode cn = new ClassNode();

reader.accept(cn, ClassReader.SKIP_DEBUG

| ClassReader.SKIP_FRAMES);

//add the class to our node list

addNode(e.getName(), cn);

} else {

//write the resource to a temporary file

File tmp = File.createTempFile("06loader", "dat");

FileOutputStream fout = new FileOutputStream(tmp);

byte[] b = new byte[1024];

int len;

while (len = in.read() >= 0) {

fout.write(b, 0, len);

}

fout.close(); // flushes and closes the file output stream

addResource(e.getName(),tmp.toURI().toURL());

tmp.deleteOnExit(); // delete the file once java closes

}

}

jf.close(); // close the jar file

}

}

最佳答案

是因为这行代码:

while (len = in.read() >= 0) {

应该是:

while ((len = in.read()) >= 0) {

编辑:正如 @Johnny Mopp 所说,这是一个优先级问题,而不是平等与赋值问题。

关于java - IDE 想要将我的 Int 转换为 boolean 值?我的方法之一说它不能应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47533871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com