Skip to content
This repository was archived by the owner on Feb 20, 2020. It is now read-only.

Commit 7af48e2

Browse files
committed
Add JDK 9 module name - fix #291
Add "9" profile to allow building on JDK 9. Override new JDK 9 Socket methods in WriteTimeoutSocket. Fix more complaints from JDK 9 javadoc. Everything here depends on javax.activation. Upgrade copyright plugin version.
1 parent db92da6 commit 7af48e2

File tree

16 files changed

+245
-22
lines changed

16 files changed

+245
-22
lines changed

android/activation/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
<execution>
110110
<id>default-compile</id>
111111
<configuration>
112-
<source>1.5</source>
113-
<target>1.5</target>
112+
<source>1.7</source>
113+
<target>1.7</target>
114114
<fork>true</fork>
115115
<!--
116116
ignore some of the errors that are
@@ -130,8 +130,8 @@
130130
<execution>
131131
<id>default-testCompile</id>
132132
<configuration>
133-
<source>1.5</source>
134-
<target>1.5</target>
133+
<source>1.7</source>
134+
<target>1.7</target>
135135
</configuration>
136136
</execution>
137137
</executions>

android/mail/src/main/java/com/sun/mail/handlers/handler_base.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,19 @@ public abstract class handler_base implements DataContentHandler {
5151
/**
5252
* Return an array of ActivationDataFlavors that we support.
5353
* Usually there will be only one.
54+
*
55+
* @return array of ActivationDataFlavors that we support
5456
*/
5557
protected abstract ActivationDataFlavor[] getDataFlavors();
5658

5759
/**
5860
* Given the flavor that matched, return the appropriate type of object.
5961
* Usually there's only one flavor so just call getContent.
62+
*
63+
* @param aFlavor the ActivationDataFlavor
64+
* @param ds DataSource containing the data
65+
* @return the object
66+
* @exception IOException for errors reading the data
6067
*/
6168
protected Object getData(ActivationDataFlavor aFlavor, DataSource ds)
6269
throws IOException {
@@ -75,9 +82,10 @@ public ActivationDataFlavor[] getTransferDataFlavors() {
7582
/**
7683
* Return the Transfer Data of type DataFlavor from InputStream.
7784
*
78-
* @param df The DataFlavor
79-
* @param ds The DataSource corresponding to the data
80-
* @return String object
85+
* @param df The DataFlavor
86+
* @param ds The DataSource corresponding to the data
87+
* @return the object
88+
* @exception IOException for errors reading the data
8189
*/
8290
public Object getTransferData(ActivationDataFlavor df, DataSource ds)
8391
throws IOException {

android/pom.xml

+31-1
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,32 @@
7676
<android.version>4.4_r1</android.version>
7777
</properties>
7878

79+
<profiles>
80+
<!--
81+
A special profile for compiling with JDK 9.
82+
Skip animal-sniffer until it works with JDK 9.
83+
-->
84+
<profile>
85+
<id>9</id>
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.codehaus.mojo</groupId>
90+
<artifactId>animal-sniffer-maven-plugin</artifactId>
91+
<configuration>
92+
<skip>true</skip>
93+
</configuration>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
</profile>
98+
</profiles>
99+
79100
<build>
80101
<plugins>
81102
<plugin>
82103
<groupId>org.codehaus.mojo</groupId>
83104
<artifactId>animal-sniffer-maven-plugin</artifactId>
84-
<version>1.14</version>
85105
<executions>
86106
<execution>
87107
<id>check-sig</id>
@@ -100,6 +120,16 @@
100120
</configuration>
101121
</plugin>
102122
</plugins>
123+
124+
<pluginManagement>
125+
<plugins>
126+
<plugin>
127+
<groupId>org.codehaus.mojo</groupId>
128+
<artifactId>animal-sniffer-maven-plugin</artifactId>
129+
<version>1.16</version>
130+
</plugin>
131+
</plugins>
132+
</pluginManagement>
103133
</build>
104134

105135
</project>

doc/release/CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ GH 278 BODYSTRUCTURE Parser fails on specific IMAP Server response
2424
GH 283 clean up connections when closing IMAPStore
2525
GH 287 Allow relaxed Content-Disposition parsing
2626
GH 289 use a different IMAP tag prefix for each connection
27+
GH 291 define JDK 9 module name for JavaMail
2728

2829

2930
CHANGES IN THE 1.6.0 RELEASE

mail/pom.xml

+57-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757
<name>JavaMail API</name>
5858

5959
<properties>
60-
<activation-api.version>1.1</activation-api.version>
6160
<mail.extensionName>
6261
javax.mail
6362
</mail.extensionName>
63+
<mail.moduleName>
64+
java.mail
65+
</mail.moduleName>
6466
<mail.specificationTitle>
6567
JavaMail(TM) API Design Specification
6668
</mail.specificationTitle>
@@ -112,6 +114,9 @@
112114
<exclude>
113115
javax/mail/MailSessionDefinitions.java
114116
</exclude>
117+
<exclude>
118+
module-info.java
119+
</exclude>
115120
</excludes>
116121
</configuration>
117122
</execution>
@@ -120,6 +125,36 @@
120125
</plugins>
121126
</build>
122127
</profile>
128+
129+
<!--
130+
A special profile for compiling with the real JDK 9 compiler.
131+
-->
132+
<profile>
133+
<id>9</id>
134+
<build>
135+
<plugins>
136+
<plugin>
137+
<artifactId>maven-compiler-plugin</artifactId>
138+
<executions>
139+
<execution>
140+
<id>default-compile</id>
141+
<configuration>
142+
<compilerArgs>
143+
<arg>-Xlint</arg>
144+
<arg>-Xlint:-options</arg>
145+
<arg>-Xlint:-path</arg>
146+
<!--
147+
Too many finalize warnings.
148+
<arg>-Werror</arg>
149+
-->
150+
</compilerArgs>
151+
</configuration>
152+
</execution>
153+
</executions>
154+
</plugin>
155+
</plugins>
156+
</build>
157+
</profile>
123158
</profiles>
124159

125160
<build>
@@ -150,6 +185,11 @@
150185
</compilerArgs>
151186
<showDeprecation>true</showDeprecation>
152187
<showWarnings>true</showWarnings>
188+
<excludes>
189+
<exclude>
190+
module-info.java
191+
</exclude>
192+
</excludes>
153193
</configuration>
154194
</plugin>
155195

@@ -166,14 +206,29 @@
166206
</includes>
167207
</configuration>
168208
</plugin>
209+
210+
<!--
211+
Add the Automatic-Module-Name manifest header for JDK 9.
212+
-->
213+
<plugin>
214+
<artifactId>maven-jar-plugin</artifactId>
215+
<configuration>
216+
<archive>
217+
<manifestEntries>
218+
<Automatic-Module-Name>
219+
${mail.moduleName}
220+
</Automatic-Module-Name>
221+
</manifestEntries>
222+
</archive>
223+
</configuration>
224+
</plugin>
169225
</plugins>
170226
</build>
171227

172228
<dependencies>
173229
<dependency>
174230
<groupId>javax.activation</groupId>
175231
<artifactId>activation</artifactId>
176-
<version>${activation-api.version}</version>
177232
</dependency>
178233
<dependency>
179234
<groupId>junit</groupId>

mail/src/main/java/com/sun/mail/handlers/handler_base.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ public abstract class handler_base implements DataContentHandler {
5252
/**
5353
* Return an array of ActivationDataFlavors that we support.
5454
* Usually there will be only one.
55+
*
56+
* @return array of ActivationDataFlavors that we support
5557
*/
5658
protected abstract ActivationDataFlavor[] getDataFlavors();
5759

5860
/**
5961
* Given the flavor that matched, return the appropriate type of object.
6062
* Usually there's only one flavor so just call getContent.
63+
*
64+
* @param aFlavor the ActivationDataFlavor
65+
* @param ds DataSource containing the data
66+
* @return the object
67+
* @exception IOException for errors reading the data
6168
*/
6269
protected Object getData(ActivationDataFlavor aFlavor, DataSource ds)
6370
throws IOException {
@@ -82,9 +89,10 @@ public DataFlavor[] getTransferDataFlavors() {
8289
/**
8390
* Return the Transfer Data of type DataFlavor from InputStream.
8491
*
85-
* @param df The DataFlavor
86-
* @param ds The DataSource corresponding to the data
87-
* @return String object
92+
* @param df The DataFlavor
93+
* @param ds The DataSource corresponding to the data
94+
* @return the object
95+
* @exception IOException for errors reading the data
8896
*/
8997
@Override
9098
public Object getTransferData(DataFlavor df, DataSource ds)

mail/src/main/java/com/sun/mail/iap/Protocol.java

+1
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ public SocketChannel getChannel() {
578578
* This implementation returns false.
579579
* Subclasses should override as appropriate.
580580
*
581+
* @return true if the server supports UTF-8
581582
* @since JavaMail 1.6.0
582583
*/
583584
public boolean supportsUtf8() {

mail/src/main/java/com/sun/mail/iap/Response.java

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public Response(String s) {
106106
/**
107107
* Constructor for testing.
108108
*
109+
* @param s the response string
110+
* @param supportsUtf8 allow UTF-8 in response?
109111
* @since JavaMail 1.6.0
110112
*/
111113
public Response(String s, boolean supportsUtf8) {
@@ -171,6 +173,7 @@ public static Response byeResponse(Exception ex) {
171173
/**
172174
* Does the server support UTF-8?
173175
*
176+
* @return true if the server supports UTF-8
174177
* @since JavaMail 1.6.0
175178
*/
176179
public boolean supportsUtf8() {
@@ -224,6 +227,9 @@ public void skipSpaces() {
224227
* Skip past any spaces. If the next non-space character is c,
225228
* consume it and return true. Otherwise stop at that point
226229
* and return false.
230+
*
231+
* @param c the character to look for
232+
* @return true if the character is found
227233
*/
228234
public boolean isNextNonSpace(char c) {
229235
skipSpaces();

mail/src/main/java/com/sun/mail/imap/protocol/IMAPProtocol.java

+4
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ public void capability() throws ProtocolException {
222222

223223
/**
224224
* Handle any untagged CAPABILITY response in the Response array.
225+
*
226+
* @param r the responses
225227
*/
226228
public void handleCapabilityResponse(Response[] r) {
227229
boolean first = true;
@@ -1174,6 +1176,8 @@ public void compress() throws ProtocolException {
11741176
* the server supports UTF-8, and add the encoded name to the
11751177
* Argument.
11761178
*
1179+
* @param args the arguments
1180+
* @param name the name to encode
11771181
* @since JavaMail 1.6.0
11781182
*/
11791183
protected void writeMailboxName(Argument args, String name) {

mail/src/main/java/com/sun/mail/smtp/package.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
message type with a "message/delivery-status"
163163
(<A HREF="http://www.ietf.org/rfc/rfc1894.txt" TARGET="_top">RFC 1894</A>)
164164
part.
165-
You can use the classes in the {@link com.sun.mail.dsn} package to
165+
You can use the classes in the <code>com.sun.mail.dsn</code> package to
166166
handle these MIME types.
167167
Note that you'll need to include <code>dsn.jar</code> in your CLASSPATH
168168
as this support is not included in <code>mail.jar</code>.

mail/src/main/java/com/sun/mail/util/LineInputStream.java

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public LineInputStream(InputStream in) {
6868
}
6969

7070
/**
71+
* @param in the InputStream
72+
* @param allowutf8 allow UTF-8 characters?
7173
* @since JavaMail 1.6
7274
*/
7375
public LineInputStream(InputStream in, boolean allowutf8) {

mail/src/main/java/com/sun/mail/util/LineOutputStream.java

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public LineOutputStream(OutputStream out) {
7171
}
7272

7373
/**
74+
* @param out the OutputStream
75+
* @param allowutf8 allow UTF-8 characters?
7476
* @since JavaMail 1.6
7577
*/
7678
public LineOutputStream(OutputStream out, boolean allowutf8) {

mail/src/main/java/com/sun/mail/util/WriteTimeoutSocket.java

+28
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
import java.io.*;
4444
import java.net.*;
4545
import java.util.concurrent.*;
46+
import java.util.Collections;
47+
import java.util.Set;
4648
import java.nio.channels.SocketChannel;
4749
import java.lang.reflect.*;
4850

@@ -314,8 +316,34 @@ public boolean isOutputShutdown() {
314316
return socket.isOutputShutdown();
315317
}
316318

319+
/*
320+
* The following three methods were added to java.net.Socket in Java SE 9.
321+
* Since they're not supported on Android, and since we know that we
322+
* never use them in JavaMail, we just stub them out here.
323+
*/
324+
//@Override
325+
public <T> Socket setOption(SocketOption<T> so, T val) throws IOException {
326+
// socket.setOption(so, val);
327+
// return this;
328+
throw new UnsupportedOperationException("WriteTimeoutSocket.setOption");
329+
}
330+
331+
//@Override
332+
public <T> T getOption(SocketOption<T> so) throws IOException {
333+
// return socket.getOption(so);
334+
throw new UnsupportedOperationException("WriteTimeoutSocket.getOption");
335+
}
336+
337+
//@Override
338+
public Set<SocketOption<?>> supportedOptions() {
339+
// return socket.supportedOptions();
340+
return Collections.emptySet();
341+
}
342+
317343
/**
318344
* KLUDGE for Android, which has this illegal non-Java Compatible method.
345+
*
346+
* @return the FileDescriptor object
319347
*/
320348
public FileDescriptor getFileDescriptor$() {
321349
try {

0 commit comments

Comments
 (0)