public int getPositionInVirtualTable( Pointer<Pointer<?>> pVirtualTable, Method method, NativeLibrary library) { // Pointer<?> typeInfo = pVirtualTable.get(1); int methodsOffset = 0; // library.isMSVC() ? 0 : -2;///2; String className = getCPPClassName(method.getDeclaringClass()); for (int iVirtual = 0; ; iVirtual++) { Pointer<?> pMethod = pVirtualTable.get(methodsOffset + iVirtual); String virtualMethodName = pMethod == null ? null : library.getSymbolName(pMethod.getPeer()); // System.out.println("#\n# At index " + methodsOffset + " + " + iVirtual + " of vptr for // class " + className + ", found symbol " + Long.toHexString(pMethod.getPeer()) + " = '" + // virtualMethodName + "'\n#"); if (virtualMethodName == null) { if (debug) info("\tVtable(" + className + ")[" + iVirtual + "] = null"); return -1; } try { MemberRef mr = library.parseSymbol(virtualMethodName); if (debug) info("\tVtable(" + className + ")[" + iVirtual + "] = " + virtualMethodName + " = " + mr); if (mr != null && mr.matchesSignature(method)) return iVirtual; else if (library.isMSVC() && !mr.matchesEnclosingType(method)) break; // no NULL terminator in MSVC++ vtables, so we have to guess when we've reached the // end } catch (Demangler.DemanglingException ex) { BridJ.warning( "Failed to demangle '" + virtualMethodName + "' during inspection of virtual table for '" + method.toGenericString() + "' : " + ex); } } return -1; }
protected <T extends CPPObject> Pointer<T> newCPPInstance( T instance, final Type type, int constructorId, Object... args) { Pointer<T> peer = null; try { final Class<T> typeClass = Utils.getClass(type); NativeLibrary lib = BridJ.getNativeLibrary(typeClass); if (BridJ.debug) info("Creating C++ instance of type " + type + " with args " + Arrays.asList(args)); Pointer.Releaser releaser = newCPPReleaser(type, typeClass, lib); long size = sizeOf(type, null); peer = (Pointer) Pointer.allocateBytes(PointerIO.getInstance(type), size, releaser).as(type); DynamicFunction constructor = constructorId == SKIP_CONSTRUCTOR ? null : getConstructor(typeClass, type, lib, constructorId); if (lib != null && CPPObject.class.isAssignableFrom(typeClass)) { installRegularVTablePtr(type, lib, peer); } else { // TODO ObjCObject : call alloc on class type !! } // Setting the C++ template parameters in the instance : int templateParametersCount = getTemplateParametersCount(typeClass); if (templateParametersCount > 0) { Object[] templateArgs = new Object[templateParametersCount]; System.arraycopy(args, 0, templateArgs, 0, templateParametersCount); setTemplateParameters(instance, typeClass, templateArgs); } // Calling the constructor with the non-template parameters : if (constructor != null) { Object[] consThisArgs = new Object[args.length - templateParametersCount + 1]; consThisArgs[0] = peer; System.arraycopy( args, templateParametersCount, consThisArgs, 1, args.length - templateParametersCount); constructor.apply(consThisArgs); } // Install synthetic virtual table and associate the Java instance to the corresponding native // pointer : if (CPPObject.class.isAssignableFrom(typeClass)) { if (installSyntheticVTablePtr(type, lib, peer)) BridJ.setJavaObjectFromNativePeer(peer.getPeer(), instance); } else { // TODO ObjCObject : call alloc on class type !! } return peer; } catch (Exception ex) { ex.printStackTrace(); if (peer != null) { peer.release(); } throw new RuntimeException("Failed to allocate new instance of type " + type, ex); } }
private void apply(org.bridj.Pointer<?> f, Object... args) { args = resolvePointers(args); Type[] classes = new Type[args.length]; for (int i = 0; i < classes.length; i++) { classes[i] = args[i].getClass(); if (args[i] instanceof String) { args[i] = Pointer.pointerToString(args[i].toString(), Pointer.StringType.C, null); classes[i] = Pointer.class; } if (args[i] instanceof Pointer) { // for all subclasses of Pointer classes[i] = Pointer.class; } // TODO is there a cleaner way (e.g. removing a layer, instead of adding one) ??? if (args[i] instanceof Float) { classes[i] = float.class; } if (args[i] instanceof Double) { classes[i] = double.class; } if (args[i] instanceof Integer) { classes[i] = int.class; } if (args[i] instanceof Long) { classes[i] = long.class; } if (args[i] instanceof Boolean) { classes[i] = boolean.class; } // System.err.println(" == "+classes[i]+" => "+args[i].getClass()+" => "+args[i]); } final DynamicFunction<Object> asDynamicFunction = f.asDynamicFunction(null, Void.TYPE, classes); asDynamicFunction.apply(args); }
protected boolean installSyntheticVTablePtr(Type type, NativeLibrary library, Pointer<?> peer) { synchronized (syntheticVirtualTables) { VTable vtable = syntheticVirtualTables.get(type); if (vtable == null) { if (!typesThatDontNeedASyntheticVirtualTable.contains(type)) { List<VirtMeth> methods = new ArrayList<VirtMeth>(); listVirtualMethods(Utils.getClass(type), methods); boolean needsASyntheticVirtualTable = false; for (VirtMeth method : methods) if (!Modifier.isNative(method.implementation.getModifiers())) { needsASyntheticVirtualTable = true; break; } if (needsASyntheticVirtualTable) { Type parentType = Utils.getParent(type); Pointer<Pointer> parentVTablePtr = null; if (CPPObject.class.isAssignableFrom(Utils.getClass(parentType))) { parentVTablePtr = peer.getPointer(Pointer.class); if (BridJ.debug) { BridJ.info( "Found parent virtual table pointer = " + ptrToString(parentVTablePtr, library)); /*Pointer<Pointer> expectedParentVTablePtr = pointerToAddress(getVirtualTable(parentType, library), Pointer.class); if (expectedParentVTablePtr != null && !Utils.eq(parentVTablePtr, expectedParentVTablePtr)) BridJ.warning("Weird parent virtual table pointer : expected " + ptrToString(expectedParentVTablePtr, library) + ", got " + ptrToString(parentVTablePtr, library)); */ } // parentVTablePtr = pointerToAddress(getVirtualTable(parentType, library), // Pointer.class); } syntheticVirtualTables.put( type, vtable = synthetizeVirtualTable(type, parentVTablePtr, methods, library)); } else { typesThatDontNeedASyntheticVirtualTable.add(type); } } } if (vtable != null) { if (BridJ.debug) BridJ.info( "Installing synthetic vtable pointer " + vtable.ptr + " to instance at " + peer + " (type = " + Utils.toString(type) + ", " + vtable.callbacks.size() + " callbacks)"); peer.setPointer(vtable.ptr); return vtable.ptr != null; } else return false; } }
public static void testSetGetIntBuffer(int n) { int[] expected = createExpectedInts(n); Pointer<Integer> p = Pointer.pointerToInts(expected); long peer = p.getPeer(); Iterator<Integer> it = p.iterator(); for (int i = 0; i < n; i++) { Integer obVal = it.next(); int val = obVal; if (val != expected[i]) throw new RuntimeException("at position i = " + i); } }
public boolean isValid() { Pointer<Integer> pCount = allocateInt(); int err; try { err = clIcdGetPlatformIDsKHR(0, null, pCount); } catch (Throwable th) { try { err = clGetPlatformIDs(0, null, pCount); } catch (Throwable th2) { return false; } } return err == OpenCLLibrary.CL_SUCCESS && pCount.get() > 0; }
@Override public Object toObject(Pointer<?> value, int size) throws InvalidAttributeException { switch (size) { case 1: return value.getByte(); case 2: return value.getShort(); case 4: return value.getInt(); case 8: return value.getLong(); } throw new InvalidAttributeException("Invalid size for int : " + size); }
public void clone(AVPacket packet) { // growing must be done here (to get the new buffer size) int growBy = packet.size() - getSize(); if (growBy > 0) grow(growBy); int res = avcodecLibrary.av_packet_copy_props( Pointer.getPointer(internal), Pointer.getPointer(packet)); if (res != 0) throw new LibavRuntimeException(res); Pointer<Byte> pData = packet.data(); if (pData != null) pData.copyTo(getData(), packet.size()); setSize(packet.size()); }
@SuppressWarnings("unchecked") public void startup( float[][] whiteTemplates, float[][] blackTemplates, int[] templateNumIndices, int[] templateIndicesOffsets, int minTemplateWidth, int maxTemplateWidth, int maxSequenceLength, int totalTemplateNumIndices) { this.templateNumIndices = templateNumIndices; this.templateIndicesOffsets = templateIndicesOffsets; this.maxTemplateWidth = maxTemplateWidth; this.minTemplateWidth = minTemplateWidth; // Allocate the device input data int extendedMaxSeqLength = (blockSizeX * rollX) * (int) Math.ceil(((double) maxSequenceLength) / (blockSizeX * rollX)); this.d_Ow = context.createFloatBuffer( Usage.Input, (extendedMaxSeqLength + maxTemplateWidth - 1) * CharacterTemplate.LINE_HEIGHT); this.d_Ob = context.createFloatBuffer( Usage.Input, (extendedMaxSeqLength + maxTemplateWidth - 1) * CharacterTemplate.LINE_HEIGHT); this.d_scores = context.createFloatBuffer(Usage.Output, maxSequenceLength * totalTemplateNumIndices); int numTemplateWidths = (maxTemplateWidth - minTemplateWidth) + 1; this.d_Tw = new CLBuffer[numTemplateWidths]; this.d_Tb = new CLBuffer[numTemplateWidths]; for (int tw = minTemplateWidth; tw <= maxTemplateWidth; ++tw) { if (templateNumIndices[tw - minTemplateWidth] > 0) { d_Tw[tw - minTemplateWidth] = context.createFloatBuffer(Usage.Input, whiteTemplates[tw - minTemplateWidth].length); d_Tw[tw - minTemplateWidth].write( queue, pc.capture(Pointer.pointerToFloats(whiteTemplates[tw - minTemplateWidth])), false); d_Tb[tw - minTemplateWidth] = context.createFloatBuffer(Usage.Input, whiteTemplates[tw - minTemplateWidth].length); d_Tb[tw - minTemplateWidth].write( queue, pc.capture(Pointer.pointerToFloats(blackTemplates[tw - minTemplateWidth])), false); } } }
@Override public Pair<Pointer<?>, Long> fromObject(Object value) { if (value instanceof Long) return new Pair<Pointer<?>, Long>(Pointer.pointerToLong(((Long) value).longValue()), 8L); else if (value instanceof Integer) return new Pair<Pointer<?>, Long>(Pointer.pointerToInt(((Integer) value).intValue()), 4L); else if (value instanceof Short) return new Pair<Pointer<?>, Long>(Pointer.pointerToShort(((Short) value).shortValue()), 2L); else if (value instanceof Byte) return new Pair<Pointer<?>, Long>(Pointer.pointerToByte(((Short) value).byteValue()), 1L); else if (value instanceof CLong) return new Pair<Pointer<?>, Long>( Pointer.pointerToCLong(((Long) value).longValue()), (long) Long.SIZE); return null; }
public synchronized void dispose() { if (internal == null) return; Pointer<AVPacket> pointer = Pointer.getPointer(internal); avcodecLibrary.av_free_packet(pointer); internal = null; // pointer.release(); }
public void compute( final float[] scores, final float[] whiteObservations, final float[] blackObservations, final int sequenceLength) { int gridSizeX = (int) Math.ceil(((double) sequenceLength) / (blockSizeX * rollX)); int extendedSeqLength = gridSizeX * (blockSizeX * rollX); d_Ow.write( queue, pc.capture( Pointer.pointerToFloats( CudaUtil.extendWithZeros( whiteObservations, (extendedSeqLength + maxTemplateWidth - 1) * CharacterTemplate.LINE_HEIGHT))), false); d_Ob.write( queue, pc.capture( Pointer.pointerToFloats( CudaUtil.extendWithZeros( blackObservations, (extendedSeqLength + maxTemplateWidth - 1) * CharacterTemplate.LINE_HEIGHT))), false); queue.enqueueBarrier(); for (int tw = minTemplateWidth; tw <= maxTemplateWidth; ++tw) { if (templateNumIndices[tw - minTemplateWidth] > 0) { int gridSizeY = (int) Math.ceil(((double) templateNumIndices[tw - minTemplateWidth]) / blockSizeY); CLKernel computeKernel = program.createKernel("compute_emissions_" + tw); computeKernel.setArgs( templateIndicesOffsets[tw - minTemplateWidth] * sequenceLength, sequenceLength, templateNumIndices[tw - minTemplateWidth], d_Tw[tw - minTemplateWidth], d_Tb[tw - minTemplateWidth], d_Ow, d_Ob, d_scores); computeKernel.enqueueNDRange( queue, new int[] {gridSizeX * blockSizeX, gridSizeY * blockSizeY}, new int[] {blockSizeX, blockSizeY}); } } queue.enqueueBarrier(); d_scores.read(queue).getFloats(scores); }
protected boolean installRegularVTablePtr(Type type, NativeLibrary library, Pointer<?> peer) { long vtablePtr = getVirtualTable(type, library); if (vtablePtr != 0) { if (BridJ.debug) BridJ.info( "Installing regular vtable pointer " + Pointer.pointerToAddress(vtablePtr) + " to instance at " + peer + " (type = " + Utils.toString(type) + ")"); peer.setSizeT(vtablePtr); return true; } return false; }
/** Lists all available OpenCL implementations. */ public static CLPlatform[] listPlatforms() { Pointer<Integer> pCount = allocateInt(); error(getPlatformIDs(0, null, pCount)); int nPlats = pCount.get(); if (nPlats == 0) return new CLPlatform[0]; Pointer<cl_platform_id> ids = allocateTypedPointers(cl_platform_id.class, nPlats); error(getPlatformIDs(nPlats, ids, null)); CLPlatform[] platforms = new CLPlatform[nPlats]; for (int i = 0; i < nPlats; i++) { platforms[i] = new CLPlatform(ids.get(i)); } return platforms; }
public void setVisible(boolean visible) { super.setVisible(visible); long hwndVal = JAWTUtils.getNativePeerHandle(this); // TODO com.sun.jna.Native.getComponentID(this); hwnd = Pointer.pointerToAddress(hwndVal); list.SetProgressValue((Pointer) hwnd, slider.getValue(), slider.getMaximum()); }
@Override public T cast(Pointer peer) { if (BridJ.isCastingNativeObjectReturnTypeInCurrentThread()) { peer = peer.withReleaser(newCPPReleaser(type)); } T instance = super.cast(peer); Object[] templateParameters = getTemplateParameters(type); setTemplateParameters(instance, (Class) typeClass, templateParameters); return instance; }
private Pointer<CThostFtdcTradeField> getTradeField() { CThostFtdcTradeField tradeField = new CThostFtdcTradeField(); tradeField.ExchangeID().setCString(交易所编号); tradeField.OrderSysID().setCString(交易所报单编号); tradeField.OrderRef().setCString(报单编号); tradeField.Volume(成交数量); tradeField.Price(成交价格); tradeField.InstrumentID().setCString(合约代码); Pointer<CThostFtdcTradeField> pTrade = Pointer.pointerTo(tradeField); return pTrade; }
private static org.bridj.Pointer[] extractNullTerminatedPointerArray(org.bridj.Pointer args) { // return args.getPointerArray(0); ArrayList<org.bridj.Pointer> res = new ArrayList<org.bridj.Pointer>(); int pointerSize = org.bridj.Pointer.SIZE; org.bridj.Pointer cur; int index = 0; while (org.bridj.Pointer.NULL != (cur = args.getPointerAtOffset(index * pointerSize))) { res.add(cur); index++; } return res.toArray(new org.bridj.Pointer[res.size()]); }
private void comm(Pointer<hid_device> device) { log.debug("starting comm loop"); Pointer<Byte> data = Pointer.allocateBytes(1024); HidapiLibrary.hid_set_nonblocking(device, 1); while (loop && connected) { int result = HidapiLibrary.hid_read(device, data, 1024); if (result > 0) { byte bytes[] = data.getBytes(result); messageQueue.addAll(parse(result, bytes)); } BpmMessage msg = writeQueue.poll(); if (msg != null) { encode(msg, writeBuffer); try { HidapiLibrary.hid_write(device, Pointer.pointerToBytes(writeBuffer), 9); } finally { writeBuffer.rewind(); } } } }
public static void testNativeTargetCallbacks() { long rawadder = getAdder_raw(); if (rawadder != 0) System.out.println( "Returned non null raw adder, cool (" + Long.toHexString(rawadder) + ") !"); else System.out.println("Returned null raw adder !"); long longadder = getAdder_long(); if (longadder != 0) System.out.println( "Returned non null longadder, cool (" + Long.toHexString(longadder) + ") !"); else System.out.println("Returned null longadder !"); long getAdder_pvoid = getAdder_pvoid(); if (getAdder_pvoid != 0) System.out.println( "Returned non null getAdder_pvoid, cool (" + Long.toHexString(getAdder_pvoid) + ") !"); else System.out.println("Returned null getAdder_pvoid !"); Pointer<org.bridj.demos.TestCPP.MyCallback> ptr = getAdder(); if (ptr == null) throw new RuntimeException("getAdder returned null adder !!!"); MyCallback adder = ptr.getNativeObject(MyCallback.class); int res = adder.doSomething(1, 2); if (res != 3) throw new RuntimeException("Expected 3, got " + res); }
public void doOptimize() { nlopt = NloptLibrary.nloptCreate(NloptAlgorithm.NLOPT_LD_MMA, start.length); IntValuedEnum<NloptResult> nloptResult = nloptSetMinObjective(nlopt, Pointer.pointerTo(object), Pointer.NULL); if (!nloptResult.equals(NloptResult.NLOPT_SUCCESS)) { throw new IllegalStateException(nloptResult.toString()); } nloptResult = NloptLibrary.nloptAddInequalityMconstraint( nlopt, inequalConstraints.getConstraintsSize(), Pointer.pointerTo(inequalConstraints), Pointer.NULL, Pointer.pointerToDoubles(inequalTolerents)); if (!nloptResult.equals(NloptResult.NLOPT_SUCCESS)) { throw new IllegalStateException(nloptResult.toString()); } nloptSetXtolRel(nlopt, objectRelativeTolerent); NloptLibrary.nloptSetXtolAbs1(nlopt, objectAbsoluteTolerence); Pointer<Double> functionResultPoint = Pointer.pointerToDouble(0); Pointer<Double> parameterPoint = Pointer.pointerToDoubles(start); if (null != initOptimizationTrigger) { Map<String, Object> initData = new HashMap<String, Object>(); initData.put("start", start); initOptimizationTrigger.accept(initData); } else { logger.warn("initOptimizationBus is null"); } resultStatus = NloptLibrary.nloptOptimize(nlopt, parameterPoint, functionResultPoint).value(); resultParameters = parameterPoint.getDoubles(); resultValue = functionResultPoint.getDouble(); NloptLibrary.nloptDestroy(nlopt); }
private Object getValueFromNative(String type, org.bridj.Pointer pointer) { NativeSymbolDemangler dem = NativeSymbolDemangler.create(); NativeType t = dem.demangleType(bundleName, type); if (t == null) { throw ex("Null native type for " + bundleName + " type " + type); } if (t.isPointer()) { return new NativePointer(pointer.getPointerAtOffset(0), t); } if (t.isCompound()) { throw ex("Unsupported direct stuct passing (use pointer or references): " + t.toString()); } // could find a way to reuse jna mapping but I didn't managed to :( try { return nativeInterpreters.get(type).interpret(pointer); } catch (NullPointerException ex) { throw ex("NPE while reading value for native type '" + type + "'", ex); } }
protected VTable synthetizeVirtualTable( Type type, Pointer<Pointer> parentVTablePtr, List<VirtMeth> methods, NativeLibrary library) { int nMethods = methods.size(); // Pointer<Pointer> parentVTablePtr = pointerToAddress(getVirtualTable(Utils.getParent(type), // library), Pointer.class); VTable vtable = new VTable(); vtable.ptr = allocatePointers(nMethods + 2) .next( 2); // leave two null pointers at index -2 and -1, to say there's no runtime type // information available. Class<?> c = Utils.getClass(type); for (int iMethod = 0; iMethod < nMethods; iMethod++) { VirtMeth vm = methods.get(iMethod); Pointer<?> pMethod; if (Modifier.isNative(vm.implementation.getModifiers())) { pMethod = parentVTablePtr == null ? null : parentVTablePtr.get(iMethod); } else { try { MethodCallInfo mci = new MethodCallInfo(vm.implementation, vm.definition); mci.setDeclaringClass(vm.implementation.getDeclaringClass()); pMethod = createCToJavaCallback(mci, c); vtable.callbacks.put(vm.implementation, pMethod); } catch (Throwable th) { BridJ.error( "Failed to register overridden method " + vm.implementation + " for type " + type + " (original method = " + vm.definition + ")", th); pMethod = null; } } vtable.ptr.set(iMethod, (Pointer) pMethod); } return vtable; }
public PooledPacket alloc() { avcodecLibrary.av_init_packet(Pointer.getPointer(internal)); bufferSize = internal.size(); return this; }
public void grow(int growBy) { int result = avcodecLibrary.av_grow_packet(Pointer.getPointer(internal), growBy); if (result != 0) throw new LibavRuntimeException(result); bufferSize = internal.size(); }
@Override public String toString(Pointer<?> value, int size) { return new String(value.getBytes(size)); }
@Override public Pair<Pointer<?>, Long> fromObject(Object value) { String s = value.toString(); return new Pair<Pointer<?>, Long>(Pointer.pointerToCString(s), (long) s.length()); }
private String ptrToString(Pointer<?> ptr, NativeLibrary library) { return ptr == null ? "null" : Long.toHexString(ptr.getPeer()) + " (" + library.getSymbolName(ptr.getPeer()) + ")"; }
static long getPtr(long peer) { Pointer<?> ptr = Pointer.pointerToAddress(peer); return ptr.getSizeT(); }
public static void main(String[] args) throws IOException { try { { JFrame f = new JFrame(); f.setVisible(true); long hwndVal = JAWTUtils.getNativePeerHandle(f); // TODO com.sun.jna.Native.getComponentID(this); System.out.println("#\n# hwndVal = " + hwndVal + "\n#"); BridJ.register(); ValuedEnum<ETest> t = testEnum(ETest.eFirst); if (t != ETest.eFirst) throw new RuntimeException(); } testSetGetIntBuffer(10); // if (Platform.isMacOSX()) { // new NSCalendar(); // new NSAutoReleasePool(); // } // NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new // File("/System/Library/Frameworks/OpenCL.framework/OpenCL")); // NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new // File("/usr/lib/libobjc.dylib")); // NativeLibrary lib = BridJ.getNativeLibrary("OpenCL", new // File("/Users/ochafik/nativelibs4java/Runtime/BridJ/src/test/cpp/test/build_out/darwin_universal_gcc_debug/libtest.dylib")); // Collection<Symbol> symbols = lib.getSymbols(); BridJ.register(MyCallback.class); BridJ.register(); int ra = testAddDyncall(10, 4); if (ra != 14) throw new RuntimeException("Expected 14, got " + ra); ra = testAddDyncall(10, 4); if (ra != 14) throw new RuntimeException("Expected 14, got " + ra); testNativeTargetCallbacks(); testJavaTargetCallbacks(); if (true) return; long crea = Ctest.createTest(); crea = Pointer.pointerToAddress(crea).getPointer().getPeer(); print("Ctest.createTest()", crea, 10, 0); Ctest test = new Ctest(); // long thisPtr = test.$this.getPeer(); // System.out.println(hex(thisPtr)); print("Ctest.this", Pointer.pointerTo(test, Ctest.class).getPointer().getPeer(), 10, 2); int res = test.testAdd(1, 2); System.out.println("res = " + res); res = test.testVirtualAdd(1, 2); System.out.println("res = " + res); res = test.testVirtualAddStdCall(null, 1, 2); System.out.println("res = " + res); res = test.testAddStdCall(null, 1, 2); System.out.println("res = " + res); TaskbarListDemo.main(null); IShellWindows win = COMRuntime.newInstance(IShellWindows.class); IUnknown iu = win.QueryInterface(IUnknown.class); if (iu == null) throw new RuntimeException("Interface does not handle IUnknown !"); win.Release(); try { new FunctionTest().add(); MyStruct s = new MyStruct(); s.a(10); System.out.println("Created MyStruct and set it to 10"); int a = Pointer.pointerTo(s).getInt(); a = s.a(); Pointer.pointerTo(s).setInt(10); a = Pointer.pointerTo(s).getInt(); a = s.a(); if (s.a() != 10) throw new RuntimeException("invalid value = " + a); s.b(100.0); if (s.b() != 100.0) throw new RuntimeException("invalid value = " + a); } catch (Throwable ex) { ex.printStackTrace(); } library = BridJ.getNativeLibrary("test"); // NativeLibrary.load(libraryPath); new VC9Demangler(null, "?sinInt@@YANH@Z").parseSymbol(); new VC9Demangler(null, "?forwardCall@@YAHP6AHHH@ZHH@Z").parseSymbol(); BridJ.register(); // new VC9Demangler(null, "??0Ctest2@@QEAA@XZ").parseSymbol(); for (Demangler.Symbol symbol : library.getSymbols()) { String name = symbol.getName(); long addr = symbol.getAddress(); System.out.println(name + " = \t" + hex(addr)); if (name.startsWith("_ZTV") || name.startsWith("_ZTI") || name.startsWith("??_")) { print("vtable", addr, 10, 1); } else System.out.println("'" + name + "'"); } boolean is64 = Platform.is64Bits(); } catch (Throwable ex) { ex.printStackTrace(); } finally { System.in.read(); } /*double dres = PerfLib.testASinB(1, 2); res = PerfLib.testAddJNI(1, 2); System.out.println("Done");*/ }