Fix for java.lang.NoClassDefFoundError: java/net/ProtocolFamily under jdk6. See #368

This commit is contained in:
norman 2012-05-30 12:16:29 +02:00
parent b98448559d
commit 1cd0aac738
2 changed files with 39 additions and 2 deletions

View File

@ -92,11 +92,11 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
// This block only works on java7++, but we checked before if we have it
switch (family) {
case INET:
channel = DatagramChannel.open(java.net.StandardProtocolFamily.INET);
channel = DatagramChannel.open(ProtocolFamilyConverter.convert(family));
break;
case INET6:
channel = DatagramChannel.open(java.net.StandardProtocolFamily.INET6);
channel = DatagramChannel.open(ProtocolFamilyConverter.convert(family));
break;
default:

View File

@ -0,0 +1,37 @@
/*
* Copyright 2011 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.jboss.netty.channel.socket.nio;
import java.net.ProtocolFamily;
final class ProtocolFamilyConverter {
private ProtocolFamilyConverter() {
}
public static ProtocolFamily convert(NioDatagramChannel.ProtocolFamily family) {
switch (family) {
case INET:
return java.net.StandardProtocolFamily.INET;
case INET6:
return java.net.StandardProtocolFamily.INET6;
default:
throw new IllegalArgumentException();
}
}
}