Merge branch '2.7'
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..4cf2927
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+# Do not merge `pom.xml` from older version, as it will typically conflict
+
+pom.xml merge=ours
diff --git a/pom.xml b/pom.xml
index 85baa70..86245fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-core</artifactId>
   <name>Jackson-core</name>
-  <version>2.7.3-SNAPSHOT</version>
+  <version>2.8.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
   <description>Core Jackson abstractions, basic JSON streaming API implementation</description>
   <inceptionYear>2008</inceptionYear>
@@ -23,7 +23,7 @@
   </scm>
 
   <properties>
-    <!-- 02-Oct-2015, tatu: Retain Java6/JDK1.6 compatibility for streaming for Jackson 2.7 -->
+    <!-- 03-Feb-2016, tatu: Retain Java6/JDK1.6 compatibility for streaming for Jackson 2.8 -->
     <javac.src.version>1.6</javac.src.version>
     <javac.target.version>1.6</javac.target.version>
 
@@ -103,8 +103,7 @@
               <encoding>UTF-8</encoding>
               <maxmemory>1g</maxmemory>
               <links>
-                  <!-- JDK, other Jackson pkgs -->
-                  <link>http://docs.oracle.com/javase/6/docs/api/</link>
+                  <link>http://docs.oracle.com/javase/7/docs/api/</link>
               </links>
               <excludePackageNames>${javadoc.package.exclude}</excludePackageNames>
               <bootclasspath>${sun.boot.class.path}</bootclasspath>
diff --git a/release-notes/VERSION b/release-notes/VERSION
index 8dfb151..085dbfd 100644
--- a/release-notes/VERSION
+++ b/release-notes/VERSION
@@ -14,6 +14,12 @@
 === Releases ===
 ------------------------------------------------------------------------
 
+2.8.0 (not yet released)
+
+#253: Add `JsonGenerator. writeEmbeddedObject()` to allow writes of opaque native types
+ (suggested by Gregoire C)
+#255: Relax ownership checks for buffers not to require increase in size
+
 2.7.2 (26-Feb-2016)
 
 #246: Fix UTF8JsonGenerator to allow QUOTE_FIELD_NAMES to be toggled
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
index 09704a4..cef4f9b 100644
--- a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
+++ b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
@@ -1236,6 +1236,17 @@
         throw new JsonGenerationException("No native support for writing Type Ids", this);
     }
 
+    /**
+     * Method that can be called on backends that support passing opaque datatypes of
+     * non-JSON formats
+     *
+     * @since 2.8
+     */
+    public void writeEmbeddedObject(Object object) throws IOException {
+        throw new JsonGenerationException("No native support for writing embedded objects",
+                this);
+    }
+
     /*
     /**********************************************************
     /* Public API, write methods, serializing Java objects
diff --git a/src/main/java/com/fasterxml/jackson/core/ObjectCodec.java b/src/main/java/com/fasterxml/jackson/core/ObjectCodec.java
index 649c89f..afa6aaa 100644
--- a/src/main/java/com/fasterxml/jackson/core/ObjectCodec.java
+++ b/src/main/java/com/fasterxml/jackson/core/ObjectCodec.java
@@ -26,9 +26,9 @@
 {
     protected ObjectCodec() { }
 
-    // Since 2.3: need baseline implementation to avoid backwards compatibility
+    // Since 2.3
     @Override
-    public Version version() { return Version.unknownVersion(); }
+    public abstract Version version();
     
     /*
     /**********************************************************
@@ -46,8 +46,8 @@
      * The reason is that due to type erasure, key and value types
      * can not be introspected when using this method.
      */
-    public abstract <T> T readValue(JsonParser jp, Class<T> valueType)
-        throws IOException, JsonProcessingException;
+    public abstract <T> T readValue(JsonParser p, Class<T> valueType)
+        throws IOException;
 
     /**
      * Method to deserialize JSON content into a Java type, reference
@@ -56,8 +56,8 @@
      * and specifically needs to be used if the root type is a 
      * parameterized (generic) container type.
      */
-    public abstract <T> T readValue(JsonParser jp, TypeReference<?> valueTypeRef)
-        throws IOException, JsonProcessingException;
+    public abstract <T> T readValue(JsonParser p, TypeReference<?> valueTypeRef)
+        throws IOException;
 
     /**
      * Method to deserialize JSON content into a POJO, type specified
@@ -65,30 +65,30 @@
      * including containers like {@link java.util.Collection} and
      * {@link java.util.Map}).
      */
-    public abstract <T> T readValue(JsonParser jp, ResolvedType valueType)
-        throws IOException, JsonProcessingException;
+    public abstract <T> T readValue(JsonParser p, ResolvedType valueType)
+        throws IOException;
 
     /**
      * Method for reading sequence of Objects from parser stream,
      * all with same specified value type.
      */
-    public abstract <T> Iterator<T> readValues(JsonParser jp, Class<T> valueType)
-        throws IOException, JsonProcessingException;
+    public abstract <T> Iterator<T> readValues(JsonParser p, Class<T> valueType)
+        throws IOException;
 
     /**
      * Method for reading sequence of Objects from parser stream,
      * all with same specified value type.
      */
-    public abstract <T> Iterator<T> readValues(JsonParser jp, TypeReference<?> valueTypeRef)
-        throws IOException, JsonProcessingException;
+    public abstract <T> Iterator<T> readValues(JsonParser p, TypeReference<?> valueTypeRef)
+        throws IOException;
     
     /**
      * Method for reading sequence of Objects from parser stream,
      * all with same specified value type.
      */
-    public abstract <T> Iterator<T> readValues(JsonParser jp, ResolvedType valueType)
-        throws IOException, JsonProcessingException;
-    
+    public abstract <T> Iterator<T> readValues(JsonParser p, ResolvedType valueType)
+        throws IOException;
+
     /*
     /**********************************************************
     /* API for serialization (Object-to-JSON)
@@ -99,8 +99,7 @@
      * Method to serialize given Java Object, using generator
      * provided.
      */
-    public abstract void writeValue(JsonGenerator jgen, Object value)
-        throws IOException, JsonProcessingException;
+    public abstract void writeValue(JsonGenerator gen, Object value) throws IOException;
 
     /*
     /**********************************************************
@@ -116,15 +115,13 @@
      * value event, not container). Empty or whitespace
      * documents return null.
      *
-     * @return next tree from jp, or null if empty.
+     * @return next tree from p, or null if empty.
      */
     @Override
-    public abstract <T extends TreeNode> T readTree(JsonParser jp)
-        throws IOException, JsonProcessingException;
+    public abstract <T extends TreeNode> T readTree(JsonParser p) throws IOException;
     
     @Override
-    public abstract void writeTree(JsonGenerator jg, TreeNode tree)
-        throws IOException, JsonProcessingException;
+    public abstract void writeTree(JsonGenerator gen, TreeNode tree) throws IOException;
     
     /**
      * Method for construct root level Object nodes
diff --git a/src/main/java/com/fasterxml/jackson/core/io/IOContext.java b/src/main/java/com/fasterxml/jackson/core/io/IOContext.java
index a4675be..18f50c8 100644
--- a/src/main/java/com/fasterxml/jackson/core/io/IOContext.java
+++ b/src/main/java/com/fasterxml/jackson/core/io/IOContext.java
@@ -270,12 +270,17 @@
     }
 
     protected final void _verifyRelease(byte[] toRelease, byte[] src) {
-        if ((toRelease != src) && (toRelease.length <= src.length)) { throw wrongBuf(); }
+        // 07-Mar-2016, tatu: As per [core#255], only prevent shrinking of buffer
+        if ((toRelease != src) && (toRelease.length < src.length)) { throw wrongBuf(); }
     }
 
     protected final void _verifyRelease(char[] toRelease, char[] src) {
-        if ((toRelease != src) && (toRelease.length <= src.length)) { throw wrongBuf(); }
+        // 07-Mar-2016, tatu: As per [core#255], only prevent shrinking of buffer
+        if ((toRelease != src) && (toRelease.length < src.length)) { throw wrongBuf(); }
     }
 
-    private IllegalArgumentException wrongBuf() { return new IllegalArgumentException("Trying to release buffer not owned by the context"); }
+    private IllegalArgumentException wrongBuf() {
+        // sanity check failed; trying to return different, smaller buffer.
+        return new IllegalArgumentException("Trying to release buffer smaller than original");
+    }
 }
diff --git a/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java b/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
index f8c31ca..686919c 100644
--- a/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
+++ b/src/main/java/com/fasterxml/jackson/core/util/JsonGeneratorDelegate.java
@@ -326,6 +326,9 @@
     
     @Override
     public void writeTypeId(Object id) throws IOException { delegate.writeTypeId(id); }
+
+    @Override
+    public void writeEmbeddedObject(Object object) throws IOException { delegate.writeEmbeddedObject(object); }
     
     /*
     /**********************************************************
diff --git a/src/test/java/com/fasterxml/jackson/core/io/TestIOContext.java b/src/test/java/com/fasterxml/jackson/core/io/TestIOContext.java
index 3bad591..475abb5 100644
--- a/src/test/java/com/fasterxml/jackson/core/io/TestIOContext.java
+++ b/src/test/java/com/fasterxml/jackson/core/io/TestIOContext.java
@@ -24,7 +24,7 @@
         try {
             ctxt.releaseReadIOBuffer(new byte[1]);
         } catch (IllegalArgumentException e) {
-            verifyException(e, "not owned");
+            verifyException(e, "smaller than original");
         }
         // but call with null is a NOP for convenience
         ctxt.releaseReadIOBuffer(null);
@@ -40,7 +40,7 @@
         try {
             ctxt.releaseWriteEncodingBuffer(new byte[1]);
         } catch (IllegalArgumentException e) {
-            verifyException(e, "not owned");
+            verifyException(e, "smaller than original");
         }
         ctxt.releaseWriteEncodingBuffer(null);
 
@@ -55,7 +55,7 @@
         try {
             ctxt.releaseTokenBuffer(new char[1]);
         } catch (IllegalArgumentException e) {
-            verifyException(e, "not owned");
+            verifyException(e, "smaller than original");
         }
         ctxt.releaseTokenBuffer(null);
 
@@ -70,7 +70,7 @@
         try {
             ctxt.releaseConcatBuffer(new char[1]);
         } catch (IllegalArgumentException e) {
-            verifyException(e, "not owned");
+            verifyException(e, "smaller than original");
         }
         ctxt.releaseConcatBuffer(null);
 
@@ -85,7 +85,7 @@
         try {
             ctxt.releaseNameCopyBuffer(new char[1]);
         } catch (IllegalArgumentException e) {
-            verifyException(e, "not owned");
+            verifyException(e, "smaller than original");
         }
         ctxt.releaseNameCopyBuffer(null);
     }