<commit_before>+++
date = "2016-06-09T12:47:43-04:00"
title = "What's New"
[menu.main]
  identifier = "Release notes"
  weight = 15
  pre = "<i class='fa fa-level-up'></i>"
+++

## What's New in 3.7

Key new features of the 3.7 Java driver release:

### Java 9 support

#### Modules

The Java driver now provides a set of JAR files that are compliant with the Java 9 
[module specification](http://cr.openjdk.java.net/~mr/jigsaw/spec/), and `Automatic-Module-Name` declarations have been added 
to the manifests of those JAR files. See the [Installation Guide]({{<ref "driver/getting-started/installation.md">}}) 
for information on which JAR files are now Java 9-compliant modules as well as what each of their module names is.  

Note that it was not possible to modularize all the existing JAR files due to the fact that, for some of them, packages are split amongst 
multiple JAR files, and this violates a core rule of the Java 9 module system which states that at most one module contains classes for any 
given package. For instance, the `mongodb-driver` and `mongodb-driver-core` JAR files both contain classes in the `com.mongodb` package, 
and thus it's not possible to make both `mongodb-driver` and `mongodb-driver-core` Java 9 modules. Also so-called 
"uber jars" like `mongo-java-driver` are not appropriate for Java 9 modularization, as they can conflict with their non-uber brethren, and 
thus have not been given module names. 

Note that none of the modular JAR files contain `module-info` class files yet.  Addition of these classes will be considered in a future 
release.

#### New Entry Point

So that the driver can offer a modular option, a new entry point has been added to the `com.mongodb.client` package. 
Static methods in this entry point, `com.mongodb.client.MongoClients`, returns instances of a new `com.mongodb.client.MongoClient` 
interface.  This interface, while similar to the existing `com.mongodb.MongoClient` class in that it is a factory for 
`com.mongodb.client.MongoDatabase` instances, does not support the legacy `com.mongodb.DBCollection`-based API, and thus does not suffer 
from the aforementioned package-splitting issue that prevents Java 9 modularization. This new entry point is encapsulated in the new 
`mongodb-driver-sync` JAR file, which is also a Java 9-compliant module.

The new entry point also moves the driver further in the direction of effective deprecation of the legacy API, which is now only available
only via the `mongo-java-driver` and `mongodb-driver` uber-jars, which are not Java 9 modules. At this point there are no plans to offer 
the legacy API as a Java 9 module.

See [Connect To MongoDB]({{<ref "driver/tutorials/connect-to-mongodb.md">}}) for details on the new `com.mongodb.client.MongoClients`
and how it compares to the existing `com.mongodb.MongoClient` class.   

### Unix domain socket support

The 3.7 driver adds support for Unix domain sockets via the [`jnr.unixsocket`](http://https://github.com/jnr/jnr-unixsocket) library.
Connecting to Unix domain sockets is done via the [`ConnectionString`]({{< apiref "com/mongodb/ConnectionString" >}}) or via
[`UnixServerAddress`]({{<apiref "com/mongodb/UnixServerAddress.html">}}).

### PojoCodec improvements

The 3.7 release brings support for `Map<String, Object>` to the `PojoCodec`.

### JSR-310 Instant, LocalDate & LocalDateTime support

Support for `Instant`, `LocalDate` and `LocalDateTime` has been added to the driver. The MongoDB Java drivers team would like to thank
[<NAME>](https://github.com/cbartosiak) for their excellent contribution to the driver. Users needing alternative data structures
and / or more flexibility regarding JSR-310 dates should check out the alternative JSR-310 codecs provider by Cezary:
[bson-codecs-jsr310](https://github.com/cbartosiak/bson-codecs-jsr310).

## What's New in 3.6

Key new features of the 3.6 Java driver release:

### Change Stream support

The 3.6 release adds support for [change streams](http://dochub.mongodb.org/core/changestreams).

* [Change Stream Quick Start]({{<ref "driver/tutorials/change-streams.md">}}) 
* [Change Stream Quick Start (Async)]({{<ref "driver-async/tutorials/change-streams.md">}})

### Retryable writes<commit_msg>Add remaining features to "What's New in 3.7" reference documentation<commit_after>+++
date = "2016-06-09T12:47:43-04:00"
title = "What's New"
[menu.main]
  identifier = "Release notes"
  weight = 15
  pre = "<i class='fa fa-level-up'></i>"
+++

## What's New in 3.7

Key new features of the 3.7 Java driver release:

### Java 9 support

#### Modules

The Java driver now provides a set of JAR files that are compliant with the Java 9 
[module specification](http://cr.openjdk.java.net/~mr/jigsaw/spec/), and `Automatic-Module-Name` declarations have been added 
to the manifests of those JAR files. See the [Installation Guide]({{<ref "driver/getting-started/installation.md">}}) 
for information on which JAR files are now Java 9-compliant modules as well as what each of their module names is.  

Note that it was not possible to modularize all the existing JAR files due to the fact that, for some of them, packages are split amongst 
multiple JAR files, and this violates a core rule of the Java 9 module system which states that at most one module contains classes for any 
given package. For instance, the `mongodb-driver` and `mongodb-driver-core` JAR files both contain classes in the `com.mongodb` package, 
and thus it's not possible to make both `mongodb-driver` and `mongodb-driver-core` Java 9 modules. Also so-called 
"uber jars" like `mongo-java-driver` are not appropriate for Java 9 modularization, as they can conflict with their non-uber brethren, and 
thus have not been given module names. 

Note that none of the modular JAR files contain `module-info` class files yet.  Addition of these classes will be considered in a future 
release.

#### New Entry Point

So that the driver can offer a modular option, a new entry point has been added to the `com.mongodb.client` package. 
Static methods in this entry point, `com.mongodb.client.MongoClients`, returns instances of a new `com.mongodb.client.MongoClient` 
interface.  This interface, while similar to the existing `com.mongodb.MongoClient` class in that it is a factory for 
`com.mongodb.client.MongoDatabase` instances, does not support the legacy `com.mongodb.DBCollection`-based API, and thus does not suffer 
from the aforementioned package-splitting issue that prevents Java 9 modularization. This new entry point is encapsulated in the new 
`mongodb-driver-sync` JAR file, which is also a Java 9-compliant module.

The new entry point also moves the driver further in the direction of effective deprecation of the legacy API, which is now only available
only via the `mongo-java-driver` and `mongodb-driver` uber-jars, which are not Java 9 modules. At this point there are no plans to offer 
the legacy API as a Java 9 module.

See [Connect To MongoDB]({{<ref "driver/tutorials/connect-to-mongodb.md">}}) for details on the new `com.mongodb.client.MongoClients`
and how it compares to the existing `com.mongodb.MongoClient` class.   

### Unix domain socket support

The 3.7 driver adds support for Unix domain sockets via the [`jnr.unixsocket`](http://https://github.com/jnr/jnr-unixsocket) library.
Connecting to Unix domain sockets is done via the [`ConnectionString`]({{< apiref "com/mongodb/ConnectionString" >}}) or via
[`UnixServerAddress`]({{<apiref "com/mongodb/UnixServerAddress.html">}}).

### PojoCodec improvements

The 3.7 release brings support for `Map<String, Object>` to the `PojoCodec`.

### JSR-310 Instant, LocalDate & LocalDateTime support

Support for `Instant`, `LocalDate` and `LocalDateTime` has been added to the driver. The MongoDB Java drivers team would like to thank
[<NAME>](https://github.com/cbartosiak) for their excellent contribution to the driver. Users needing alternative data structures
and / or more flexibility regarding JSR-310 dates should check out the alternative JSR-310 codecs provider by Cezary:
[bson-codecs-jsr310](https://github.com/cbartosiak/bson-codecs-jsr310).

### JSR-305 NonNull annotations

The public API is now annotated with JSR-305 compatible `@NonNull` and `@Nullable` annotations.  This will allow programmers
to rely on tools like FindBugs/SpotBugs, IDEs like IntelliJ IDEA, and compilers like the Kotlin compiler to find errors in the use of the 
driver via static analysis rather than via runtime failures.

### Improved logging of commands

When the log level is set to DEBUG for the `org.mongodb.driver.protocol.command` logger, the driver now logs additional information to aid
in debugging:

* Before sending the command, it logs the full command (up to 1000 characters), and the request id.
* After receive a response to the command, it logs the request id and elapsed time in milliseconds.

Here's an example

```
10:37:29.099 [cluster-ClusterId {value='5a466138741fc252712a6d71', description='null'}-127.0.0.1:27017] DEBUG org.mongodb.driver.protocol.command - 
Sending command '{ "ismaster" : 1, "$db" : "admin" } ...' with request id 4 to database admin on connection [connectionId{localValue:1, serverValue:1958}] to server 127.0.0.1:27017
10:37:29.104 [cluster-ClusterId{value='5a466138741fc252712a6d71', description='null'}-127.0.0.1:27017] DEBUG org.mongodb.driver.protocol.command - 
Execution of command with request id 4 completed successfully in 22.44 ms on connection [connectionId {localValue:1, serverValue:1958}] to server 127.0.0.1:27017
```
 
### Improved support for "raw" documents

When working with "raw" BSON for improved performance via the [`RawBsonDocument`]({{<apiref "org/bson/RawBsonDocument">}}), the efficiency
of accessing embedded documents and arrays has been drastically improved by returning raw slices of the containing document or array.  For
instance

```java
RawBsonDocument doc = new RawBsonDocument(bytes);

// returns a RawBsonDocument that is a slice of the bytes from the containing doc
BsonDocument embeddedDoc = doc.getDocument("embeddedDoc");

// returns a RawBsonArray that is a slice of the bytes from the containing doc
BsonArray embeddedArray = doc.getArray("embeddedArray");

// returns a RawBsonDocument that is a slice of the bytes from the containing array 
BsonDocument embeddedDoc2 = (BsonDocument) embeddedArray.get(0); 
``` 

## What's New in 3.6

Key new features of the 3.6 Java driver release:

### Change Stream support

The 3.6 release adds support for [change streams](http://dochub.mongodb.org/core/changestreams).

* [Change Stream Quick Start]({{<ref "driver/tutorials/change-streams.md">}}) 
* [Change Stream Quick Start (Async)]({{<ref "driver-async/tutorials/change-streams.md">}})

### Retryable writes
{'fraction_non_alphanumeric': 0.09238625812441968, 'fraction_numerical': 0.023119777158774373, 'mean_word_length': 4.7262094630515685, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2629897', 'n_tokens_mistral': 3381, 'n_tokens_neox': 3066, 'n_words': 1347}