java 8 与 java 7 , 包 与 类 新增和删除的对比
java8 新增:
java.time java.util.function java.util.stream com.sun.source.doctree com.sun.org.apache.xml.internal.security.signature.reference
java.beans.MethodRef.java java.io.DefaultFileSystem.java java.io.UncheckedIOException.java java.lang.FunctionalInterface.java java.net.HostPortrange.java java.net.HttpConnectSocketImpl.java java.net.InetAddressContainer.java java.net.package-info.java java.net.URLPermission.java java.nio.CharBufferSpliterator.java java.security.DomainLoadStoreParameter.java java.security.package-info.java java.security.PKCS12Attribute.java java.sql.DriverAction.java java.sql.JDBCType.java java.sql.SQLType.java java.util.ArrayPrefixHelpers.java java.util.ArraysParallelSortHelpers.java java.util.Base64.java java.util.Comparators.java java.util.DoubleSummaryStatistics.java java.util.IntSummaryStatistics.java java.util.LongSummaryStatistics.java java.util.Optional.java java.util.OptionalDouble.java java.util.OptionalInt.java java.util.OptionalLong.java java.util.PrimitiveIterator.java java.util.Spliterator.java java.util.Spliterators.java java.util.SplittableRandom.java java.util.StringJoiner.java java.util.Tripwire.java javax.tools.DocumentationTool.java com.sun.javadoc.AnnotatedType.java com.sun.javadoc.package-info.java java.lang.annotation.Native.java java.lang.annotation.Repeatable.java java.lang.invoke.AbstractValidatingLambdaMetafactory.java java.lang.invoke.InfoFromMemberName.java java.lang.invoke.InnerClassLambdaMetafactory.java java.lang.invoke.LambdaConversionException.java java.lang.invoke.LambdaMetafactory.java java.lang.invoke.ProxyClassesDumper.java java.lang.invoke.SerializedLambda.java java.lang.invoke.Stable.java java.lang.invoke.TypeConvertingMethodAdapter.java java.lang.reflect.AnnotatedArrayType.java java.lang.reflect.AnnotatedParameterizedType.java java.lang.reflect.AnnotatedType.java java.lang.reflect.AnnotatedTypeVariable.java java.lang.reflect.AnnotatedWildcardType.java java.lang.reflect.Executable.java java.lang.reflect.MalformedParametersException.java java.lang.reflect.Parameter.java java.lang.reflect.WeakCache.java java.nio.file.FileTreeIterator.java java.security.acl.package-info.java java.security.cert.CertPathChecker.java java.security.cert.package-info.java java.security.cert.PKIXRevocationChecker.java java.security.interfaces.package-info.java java.security.spec.DSAGenParameterSpec.java java.security.spec.package-info.java java.util.concurrent.CompletableFuture.java java.util.concurrent.CompletionException.java java.util.concurrent.CompletionStage.java java.util.concurrent.CountedCompleter.java java.util.spi.CalendarDataProvider.java java.util.spi.CalendarNameProvider.java java.util.spi.ResourceBundleControlProvider.java java.util.zip.ZipUtils.java javax.lang.model.AnnotatedConstruct.java javax.management.timer.TimerAlarmClock.java javax.rmi.CORBA.ClassDesc.java javax.rmi.CORBA.GetORBPropertiesFileAction.java javax.rmi.CORBA.PortableRemoteObjectDelegate.java javax.rmi.CORBA.Stub.java javax.rmi.CORBA.StubDelegate.java javax.rmi.CORBA.Tie.java javax.rmi.CORBA.Util.java javax.security.auth.package-info.java javax.security.cert.package-info.java javax.security.sasl.package-info.java javax.xml.validation.SchemaFactoryConfigurationError.java com.sun.jmx.snmp.SnmpPermission.java com.sun.security.auth.package-info.java com.sun.security.jgss.ExtendedGSSCredential.java com.sun.security.jgss.package-info.java com.sun.source.tree.AnnotatedTypeTree.java com.sun.source.tree.IntersectionTypeTree.java com.sun.source.tree.LambdaExpressionTree.java com.sun.source.tree.MemberReferenceTree.java com.sun.source.util.DocSourcePositions.java com.sun.source.util.DocTreePath.java com.sun.source.util.DocTreePathScanner.java com.sun.source.util.DocTrees.java com.sun.source.util.DocTreeScanner.java com.sun.source.util.Plugin.java com.sun.source.util.SimpleDocTreeVisitor.java java.util.concurrent.atomic.DoubleAccumulator.java java.util.concurrent.atomic.DoubleAdder.java java.util.concurrent.atomic.LongAccumulator.java java.util.concurrent.atomic.LongAdder.java java.util.concurrent.atomic.Striped64.java java.util.concurrent.locks.StampedLock.java javax.lang.model.type.IntersectionType.java javax.lang.model.util.AbstractAnnotationValueVisitor8.java javax.lang.model.util.AbstractElementVisitor8.java javax.lang.model.util.AbstractTypeVisitor8.java javax.lang.model.util.ElementKindVisitor8.java javax.lang.model.util.ElementScanner8.java javax.lang.model.util.SimpleAnnotationValueVisitor8.java javax.lang.model.util.SimpleElementVisitor8.java javax.lang.model.util.SimpleTypeVisitor8.java javax.lang.model.util.TypeKindVisitor8.java javax.security.auth.callback.package-info.java javax.security.auth.kerberos.package-info.java javax.security.auth.login.package-info.java javax.security.auth.spi.package-info.java javax.security.auth.x500.package-info.java com.sun.imageio.plugins.bmp.BMPCompressionTypes.java com.sun.jmx.snmp.agent.AcmChecker.java com.sun.jmx.snmp.agent.LongList.java com.sun.security.auth.callback.package-info.java com.sun.security.auth.login.package-info.java com.sun.security.auth.module.package-info.java com.sun.corba.se.impl.util.IdentityHashtableEntry.java com.sun.org.apache.xalan.internal.utils.FeatureManager.java com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.java com.sun.org.apache.xalan.internal.utils.XMLSecurityManager.java com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer.java com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.java com.sun.org.apache.xml.internal.security.encryption.AbstractSerializer.java com.sun.org.apache.xml.internal.security.encryption.DocumentSerializer.java com.sun.org.apache.xml.internal.security.encryption.Serializer.java com.sun.org.apache.xml.internal.security.utils.ClassLoaderUtils.java com.sun.org.apache.xml.internal.security.utils.DOMNamespaceContext.java com.sun.org.apache.xml.internal.security.utils.JDKXPathAPI.java com.sun.org.apache.xml.internal.security.utils.JDKXPathFactory.java com.sun.org.apache.xml.internal.security.utils.Signature11ElementProxy.java com.sun.org.apache.xml.internal.security.utils.XalanXPathAPI.java com.sun.org.apache.xml.internal.security.utils.XalanXPathFactory.java com.sun.org.apache.xml.internal.security.utils.XPathAPI.java com.sun.org.apache.xml.internal.security.utils.XPathFactory.java com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages_pt_BR.java com.sun.org.apache.xml.internal.security.c14n.implementations.CanonicalizerPhysical.java com.sun.org.apache.xml.internal.security.keys.content.DEREncodedKeyValue.java com.sun.org.apache.xml.internal.security.keys.content.KeyInfoReference.java com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverContext.java com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Digest.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DEREncodedKeyValueResolver.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.KeyInfoReferenceResolver.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.PrivateKeyResolver.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.SecretKeyResolver.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.SingleKeyResolver.java com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509DigestResolver.java
java8 删除:
sunw com.sun.mirror com.sun.jmx.trace java.io.Win32FileSystem.java java.net.NetUtil.java java.text.BreakDictionary.java java.text.CollationRules.java java.text.DictionaryBasedBreakIterator.java java.text.RuleBasedBreakIterator.java java.util.XMLUtils.java java.lang.invoke.InvokeGeneric.java com.sun.security.auth.PolicyParser.java com.sun.security.auth.SubjectCodeSource.java com.sun.org.apache.bcel.internal.util.Objects.java com.sun.org.apache.xalan.internal.utils.Objects.java com.sun.org.apache.xerces.internal.utils.Objects.java com.sun.org.apache.xml.internal.security.utils.CachedXPathAPIHolder.java com.sun.org.apache.xml.internal.security.utils.CachedXPathFuncHereAPI.java com.sun.org.apache.xml.internal.security.utils.XPathFuncHereAPI.java com.sun.org.apache.xml.internal.security.transforms.implementations.FuncHereContext.java
对比方法:
下载jdk7 和jdk8 ,解压其中的src.zip文件,分别放在 D:\\tmp\\java7 和 D:\\tmp\\java8 下面
使用如下代码进行处理(jdk8编译运行):
package test; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.WeakHashMap; public class Main { public static void main(String[] args) throws IOException { // 比较 File java7 = new File("D:\\tmp\\java7"); File java8 = new File("D:\\tmp\\java8"); Pair<File, File> root = new Pair<>(java7, java8); Queue<Pair<File, File>> queue = new LinkedList<>(); queue.add(root); List<File> removed = new LinkedList<>(); List<File> add = new LinkedList<>(); while (!queue.isEmpty()) { Pair<File, File> p = queue.poll(); File j7dir = p.getFirst(); File j8dir = p.getSecond(); if (j7dir.isDirectory()) { List<File> j7files = Arrays.asList(j7dir.listFiles()); List<File> j8files = Arrays.asList(j8dir.listFiles()); Map<String, File> j7names = getFileNames(j7files); Map<String, File> j8names = getFileNames(j8files); j7files.forEach(j7file -> { if (!j8names.containsKey(j7file.getName())) { removed.add(j7file); } else { queue.add(new Pair<File, File>(j7file, j8names .get(j7file.getName()))); } }); j8files.forEach(j8file -> { if (!j7names.containsKey(j8file.getName())) { add.add(j8file); } }); } } // 排序,匿名类型对象似乎无法传递 add.sort((a, b) -> { if (a.getName().endsWith(".java")) { if (b.getName().endsWith(".java")) { return 0; } return 1; } if (b.getName().endsWith(".java")) { return -1; } return 0; }); removed.sort((a, b) -> { if (a.getName().endsWith(".java")) { if (b.getName().endsWith(".java")) { return 0; } return 1; } if (b.getName().endsWith(".java")) { return -1; } return 0; }); // 写文件 File addFiles = new File("D:\\tmp\\add.txt"); File removeFiles = new File("D:\\tmp\\remove.txt"); if (addFiles.exists()) { addFiles.delete(); } if (removeFiles.exists()) { removeFiles.delete(); } FileWriter aw = new FileWriter(addFiles); FileWriter rw = new FileWriter(removeFiles); // 不需要加final修饰符,可能是编译器处理 int la = "D:\\tmp\\java8\\".length(); add.forEach(file -> { try { aw.write(file.getCanonicalPath().substring(la) .replace(‘\\‘, ‘.‘) + "\n"); } catch (Exception e) { e.printStackTrace(); } }); int lr = "D:\\tmp\\java7\\".length(); removed.forEach(file -> { try { rw.write(file.getCanonicalPath().substring(lr) .replace(‘\\‘, ‘.‘) + "\n"); } catch (Exception e) { e.printStackTrace(); } }); aw.close(); rw.close(); } private static Map<String, File> getFileNames(List<File> files) { Map<String, File> map = new WeakHashMap<>(); files.forEach(file -> { map.put(file.getName(), file); }); return map; } static class Pair<T, R> { private T t; private R r; public Pair(T t, R r) { this.t = t; this.r = r; } public T getFirst() { return t; } public void setFrist(T t) { this.t = t; } public R getSecond() { return r; } public void setSecond(R r) { this.r = r; } } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。