public HttpsClient() { String trustStore = System.getProperty("javax.net.ssl.trustStore"); // 抑制证书域名与实际域名不匹配的警告 HostnameVerifier hv = new HostnameVerifier() { public boolean verify(String urlHostName, SSLSession session) { System.out.println( "Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost()); return true; } }; HttpsURLConnection.setDefaultHostnameVerifier(hv); String nonce = String.valueOf(Math.random() * 1000000); String timestamp = String.valueOf(System.currentTimeMillis() / 1000); StringBuilder toSign = new StringBuilder(appSecret).append(nonce).append(timestamp); String sign = CodeUtil.hexSHA1(toSign.toString()); // 初始化请求参数 reqProperty = new HashMap<String, String>(); reqProperty.put("Content-Type", "text/xml"); reqProperty.put(APPKEY, appKey); reqProperty.put(NONCE, nonce); reqProperty.put(TIMESTAMP, timestamp); reqProperty.put(SIGNATURE, sign); reqProperty.put("Content-Type", "application/x-www-form-urlencoded"); }
@Override public long getMemorySize(Constant constant) { if (constant.getKind() == Kind.Object) { HotSpotResolvedObjectType lookupJavaType = (HotSpotResolvedObjectType) this.lookupJavaType(constant); if (lookupJavaType == null) { return 0; } else { if (lookupJavaType.isArray()) { // TODO(tw): Add compressed pointer support. int length = Array.getLength(HotSpotObjectConstant.asObject(constant)); ResolvedJavaType elementType = lookupJavaType.getComponentType(); Kind elementKind = elementType.getKind(); final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind); int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind); int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize; int log2ElementSize = CodeUtil.log2(sizeOfElement); return NewObjectSnippets.computeArrayAllocationSize( length, alignment, headerSize, log2ElementSize); } return lookupJavaType.instanceSize(); } } else { return constant.getKind().getByteCount(); } }
public static void main(String args[]) { MD5 md5 = new MD5(); String s = "1234\u60A8\u597D5678"; byte abyte0[] = md5.calculate(s); System.out.println(abyte0.length); System.out.println( (new StringBuilder()) .append("MD5(\"") .append(s) .append("\"):") .append(CodeUtil.Bytes2FormattedText(abyte0)) .toString()); }
protected InstalledCode assembleMethod(Method m, CodeGenTest test) { ResolvedJavaMethod method = codeCache.lookupJavaMethod(m); RegisterConfig registerConfig = codeCache.lookupRegisterConfig(); CallingConvention cc = CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false); CompilationResult compResult = new CompilationResult(); Buffer codeBuffer = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc); compResult.setTargetCode(codeBuffer.close(true), codeBuffer.position()); InstalledCode code = codeCache.addMethod(method, compResult); DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class); if (dis != null) { String disasm = dis.disassemble(code); Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0); } return code; }
@Override public String toString() { return CodeUtil.append(new StringBuilder(100), this).toString(); }