EMMA Coverage Report (generated Mon Mar 20 21:34:30 PST 2006)
[all classes][com.moesol.bindings.platform_sdk.windows_api]

COVERAGE SUMMARY FOR SOURCE FILE [HANDLE.java]

nameclass, %method, %block, %line, %
HANDLE.java100% (1/1)89%  (8/9)79%  (69/87)85%  (17.1/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HANDLE100% (1/1)89%  (8/9)79%  (69/87)85%  (17.1/20)
hashCode (): int 0%   (0/1)0%   (0/4)0%   (0/1)
detach (): void 100% (1/1)71%  (10/14)87%  (2.6/3)
HANDLE (long, boolean): void 100% (1/1)79%  (15/19)94%  (3.8/4)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
equals (Object): boolean 100% (1/1)83%  (15/18)73%  (2.9/4)
HANDLE (long): void 100% (1/1)100% (5/5)100% (2/2)
_getHandle (): long 100% (1/1)100% (3/3)100% (1/1)
_safeGetHandle (HANDLE): long 100% (1/1)100% (7/7)100% (3/3)
getLeakCount (): long 100% (1/1)100% (2/2)100% (1/1)

1/*
2 * $Id: HANDLE.java,v 1.3 2004/08/16 18:39:52 hastings Exp $
3 *
4 * (c) Copyright, Moebius Solutions, Inc., 2004
5 *
6 *                       All Rights Reserved
7 *
8 * This material may be reproduced by or for the U. S. Government
9 * pursuant to the copyright license under the clause at
10 * DFARS 252.227-7014 (OCT 2001).
11 */
12 
13package com.moesol.bindings.platform_sdk.windows_api;
14 
15 
16/**
17 * An opaque HANDLE that represents a Win32 HANDLE.
18 * It is opaque from java side, only JNI can set the m_handle field, usually
19 * by calling the protected constructor. When assertions are turned on
20 * this class does leak detection.
21 */
22public class HANDLE {
23    /** 
24     * Returns the native handle.
25     */
26    public long _getHandle() {
27        return m_handle;
28    }
29    /** 
30     * Returns the native handle of <code>handle</code>.
31     * Safe to call for null handles, returns 0 in this case.
32     * 
33     * @param handle
34     * @return native handle or 0 if handle is null.
35     */
36    public static long _safeGetHandle(HANDLE handle) {
37            if (handle == null) {
38                    return 0;
39            }
40            return handle.m_handle;
41    }
42    public boolean equals(Object o) {
43        if (!(o instanceof HANDLE)) {
44            return false;
45        }
46        HANDLE other = (HANDLE)o;
47        return m_handle == other.m_handle;
48    }
49    public int hashCode() {
50        return (int)m_handle;
51    }
52    public void detach() {
53        assert(NativeResourceRef.removeCreateLocation(m_handle));
54        m_handle = 0;
55    }
56    public static long getLeakCount() {
57            return NativeResourceRef.getLeakCount();
58    }
59 
60    /**
61     * Create a temporary handle that is not reported as
62     * leaked if finalize is called and m_handle is non-zero.
63     * 
64     * @param handle
65     * @param temporary - if false same as calling HANDLE(long)
66     */
67    protected HANDLE(long handle, boolean temporary) {
68        m_handle = handle;
69        assert(temporary || NativeResourceRef.recordCreateLocation(this, m_handle));
70    }
71    /**
72     * Create a tracked handle that will report as leaked
73     * if it is finalized befre being detached.
74     * 
75     * @param handle
76     */
77    protected HANDLE(long handle) {
78        this(handle, false);
79    }
80    
81        private long m_handle;
82}

[all classes][com.moesol.bindings.platform_sdk.windows_api]
EMMA 2.0.5312 (C) Vladimir Roubtsov