本文整理汇总了Java中cuchaz.enigma.Constants.MiB方法的典型用法代码示例。如果您正苦于以下问题:Java Constants.MiB方法的具体用法?Java Constants.MiB怎么用?Java Constants.MiB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cuchaz.enigma.Constants
的用法示例。
在下文中一共展示了Constants.MiB方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClass
import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry) throws IOException, NotFoundException {
// read the class into a buffer
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[Constants.KiB];
int totalNumBytesRead = 0;
InputStream in = jar.getInputStream(entry);
while (in.available() > 0) {
int numBytesRead = in.read(buf);
if (numBytesRead < 0) {
break;
}
bos.write(buf, 0, numBytesRead);
// sanity checking
totalNumBytesRead += numBytesRead;
if (totalNumBytesRead > Constants.MiB) {
throw new Error("Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!");
}
}
// get a javassist handle for the class
String className = Descriptor.toJavaName(getClassEntry(entry).getName());
ClassPool classPool = new ClassPool();
classPool.appendSystemPath();
classPool.insertClassPath(new ByteArrayClassPath(className, bos.toByteArray()));
return classPool.get(className);
}
示例2: getClass
import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry) throws IOException, NotFoundException {
// read the class into a buffer
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[Constants.KiB];
int totalNumBytesRead = 0;
InputStream in = jar.getInputStream(entry);
while (in.available() > 0) {
int numBytesRead = in.read(buf);
if (numBytesRead < 0) {
break;
}
bos.write(buf, 0, numBytesRead);
// sanity checking
totalNumBytesRead += numBytesRead;
if (totalNumBytesRead > Constants.MiB) {
throw new Error("Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!");
}
}
// get a javassist handle for the class
String className = Descriptor.toJavaName(getClassEntry(entry).getName());
ClassPool classPool = new ClassPool();
classPool.appendSystemPath();
classPool.insertClassPath(new ByteArrayClassPath(className, bos.toByteArray()));
return classPool.get(className);
}
示例3: getClass
import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry)
throws IOException, NotFoundException
{
// read the class into a buffer
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[Constants.KiB];
int totalNumBytesRead = 0;
InputStream in = jar.getInputStream(entry);
while(in.available() > 0)
{
int numBytesRead = in.read(buf);
if(numBytesRead < 0)
break;
bos.write(buf, 0, numBytesRead);
// sanity checking
totalNumBytesRead += numBytesRead;
if(totalNumBytesRead > Constants.MiB)
throw new Error("Class file " + entry.getName()
+ " larger than 1 MiB! Something is wrong!");
}
// get a javassist handle for the class
String className =
Descriptor.toJavaName(getClassEntry(entry).getName());
ClassPool classPool = new ClassPool();
classPool.appendSystemPath();
classPool.insertClassPath(new ByteArrayClassPath(className, bos
.toByteArray()));
return classPool.get(className);
}