commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1166788 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl: NativePointer.java PasswordCallback.java
Date Thu, 08 Sep 2011 16:38:01 GMT
Author: mturk
Date: Thu Sep  8 16:38:01 2011
New Revision: 1166788

URL: http://svn.apache.org/viewvc?rev=1166788&view=rev
Log:
Make sure hidden pointer is final

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java?rev=1166788&r1=1166787&r2=1166788&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/NativePointer.java
Thu Sep  8 16:38:01 2011
@@ -19,17 +19,36 @@ package org.apache.commons.runtime.ssl;
 import org.apache.commons.runtime.Callback;
 
 /**
- * Abstract native pointer place holder
+ * Abstract native pointer envelope.
+ * This is package private generic pointer wrapper.
+ * Package classes can cast derived classes to NativePointer and
+ * obtain access to its native pointer.
+ * <p>
+ * Derived classes must declare {@code private final long pointer = 0L;}
+ * so that pointer is not visible ouside the package. Inside derived
+ * classes {@code super.pointer} must be used so that we reference
+ * the correct native object.
+ * </p>
  */
 abstract class NativePointer
 {
     public long        pointer;
 
     /**
-     * Creates a new object instance
+     * Creates a new object instance.
      */
     protected NativePointer()
     {
+        this.pointer = 0L;
+    }
+
+    /**
+     * Creates a new object instance with already allocated pointer.
+     * @param pointer already allocated native pointer.
+     */
+    protected NativePointer(long pointer)
+    {
+        this.pointer = pointer;
     }
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java?rev=1166788&r1=1166787&r2=1166788&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/PasswordCallback.java
Thu Sep  8 16:38:01 2011
@@ -24,9 +24,11 @@ import org.apache.commons.runtime.Callba
 public abstract class PasswordCallback
     extends NativePointer implements Callback
 {
+
+    // Hide NativePointer
+    private final long  pointer = 0L;
+    
     private String      prompt;
-    // Hide native pointer
-    private long        pointer;
     private native long new0();
     private native void def0(long pointer);
     private native void del0(long pointer);
@@ -52,7 +54,7 @@ public abstract class PasswordCallback
     protected PasswordCallback(String prompt)
     {
         super.pointer = new0();
-        this.prompt  = prompt;
+        this.prompt   = prompt;
     }
 
     @Override



Mime
View raw message