In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what are the changes from java8 to java17 api". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Start with the changes from jdk8 to 9
There is no need for many people to say java.applet, abandon part of api.
Java.awt most of the api changes, the detailed method is not very useful.
Add java.awt.desktop some desktop operations, screen, sleep, drag, Ui, etc.
Some new ui, events, focus, pictures, taskbar, some deletions, etc. Robot uses multiple points, adds a multi-screen
Java.beans added @ BeanProperty@JavaBean comment information and so on.
Java.io is a common point.
InputStream has added readAllBytes (), so you don't have to do utility classes to read bytes directly, but it is not recommended for streams that are too large. ReadNBytes method is recommended for byte reading. TransferTo can directly copy the output stream.
OutputStreamWriter adds the append method to append strings directly.
There are also some new methods for other corresponding subclasses and output streams, such as filtering configuration, etc.
Enumerated MODULE is added under java.lang.annotation, which mainly corresponds to the corresponding module.
Java.lang.instrument Instrumentation added whether the isModifiableModule module supports modification, and redefineModule redefines the module.
Java.lang.invoke package MethodHandle and MethodHandles add a lot of methods, add a little bit of things do not write.
StringConcatFactory has been added, and the string constant pool is used to create methods that optimize string concatenation.
The practical part is that many of the reflections can be obtained through the handle. Added VarHandle, which supports a variety of variable operation access, memory barrier sorting is very practical, a lot of people write their own search. Personally, it is recommended to use the api under this package instead of reflection, and then use aot to compile the machine code without reflection configuration.
Java.lang.management ThreadInfo added priority and daemon thread flags
Java.lang.module modular package there is nothing to say, modularization depends on it, basically java9 class loading and 8 before is a big change, extension class out of the stage is mainly platform class loader, not to mention the details of the most practical part is the use of modular jre can be much smaller memory footprint.
Java.lang.ref added Cleaner, object cleanup, which uses virtual references and reference queues to notify cleanup when objects change from the strongest to the weakest. The clean method in the Cleaner.Cleanable implementation interface can cancel the call cleanup.
The canAccess method has been added to AccessibleObject in java.lang.reflect reflection to determine whether the object is accessible or not. The trySetAccessible method attempts to set the tag. SetAccessible has been added to Constructor,Field,Method.
Two static methods of Proxy are deprecated
Java.lang is the most important package with a little more detail. Many new with basic wrapper type are not used anymore, and there are more modules.
ForRemoval () and since () have been added to Deprecated annotations to indicate deletion and enablement of versions
Byte,short added compareUnsigned comparison 0x = y0x
< y0x >Y
Character. Many character sets have been added and too many single code constants have not been posted.
ClassLoader adds a lot of practical methods to get packages, loaders, platforms, resources, etc., mainly modular changes
Class added getting classes, packages and modules according to the module, and deprecated the newInstance () suggestion constructor.
The Compiler jit compiler is so different that it is deprecated
Integer Long added parseInt, parseUnsignedInt (CharSequence, int, int, int), and long corresponds to long.
Seven new practical methods floorDiv,floorMod,fma (double and float), multiply Exact,Full,High are added to Math
Related to Module,ModuleLayer,ModuleLayer.Controller,Package module
ProcessBuilder added enumeration of DISCARD and startPipeline enabled stream link
Process added children () child process, descendants () snapshot, info () information snapshot, onExit () termination process
Pid () returns the process id,supportsNormalTermination () termination judgment toHandle () returns the handle. It's practical.
Runtime.Version javase version string.
StackWalker new class, thread snapshot stack printing is very convenient
Added chars character inflow and codePoints code inflow to String. Char array byet array, a lot of details are optimized, such as + these optimizations are better, the main api does not say the details.
System has added two new methods for getLogger. Mainly the log jvm log is also included. Specify module with java.logging can specify slf4j, I will use it to achieve a simple log observation jvm is more convenient.
Thread added a new constructor, added onSpinWait () to tell cpu that I am in a loop, improve the efficiency of optional, practical.
Java.math BigInteger,BigDecimal rounding, square root methods
The provider extension in the java.net.spi java.net package makes it convenient to customize some url protocols and so on.
Java.net authentication, proxy, tcp,udp,ip these add a lot of practical configuration parameters, easy to obtain.
Java.nio various buffer add reset stream buffer marks and so on more convenient.
ExportObject has been added to java.rmi.server UnicastRemoteObject. It's troublesome to export directly without jndi.
Too many new additions to java.security. The multipoint used by SecureRandom adds several practical methods.
Java.security.acl Acl these have been replaced by Policy, discarded
Java.security.cert added uri defined by URICertStoreParameters,RFC 5280 to provide the necessary parameters to the algorithm implementation.
Most of the java.security.spec algorithms are deleted out of date, and several new methods have been added.
The jdbc of java.sql is used a lot.
DriverManager added drivers method to get driver flow
Construction of ConnectionBuilder connection
Connection adds several default methods before and after request, sets sharding verification, etc.
SupportsSharding has been added to DatabaseMetaData to retrieve whether sharding is supported. The other several are sharding interfaces that are not written.
Java.time adds several practical methods to the date of java8
Although there are too many new additions to java.util.concurrent.atomic, it has enhanced a lot of methods.
Java.util.concurrent is not the same method as above, just talk about the new class.
Flow . There are several subscription publishing interfaces, which do not need rxjava.
SubmissionPublisher . Asynchronously submit (non-empty) items to the current subscriber until they are closed
Java.util.jar deleted attribute snooping in Pack200.
JarFile adds multi-version java jar utility for baseVersion,getVersion,isMultiRelease,runtimeVersion writing framework
Java.util.logging is simply mentioned above, and there are many enhancements.
New replaceAll replaceFirst appendTail appendReplacement enhancements to java.util.regex Matcher
Result stream of results matching
The following three are mainly added to java.util.spi, such as developing javac,jar,jlink and so on
The interface of the ToolProvider command line tool to provide a method to be called without necessarily starting a new VM
The provider interface used by ResourceBundleProvider to load the resource bundle for the specified module
AbstractResourceBundleProvider basic Abstract Class
A new method has been added to java.util.stream, which makes it easier to use on the stream side.
Delete two methods of java.util.zip, add CRC32C class, and extend the get/setTimeLocal of ZipEntry
Many new methods have been added to java.util, such as set queue map and other functions that support streams. It is too important to choose the ones that use the most.
Various types of enhancements to Arrays compare,compareUnsigned,equals,mismatch
Objects requireNonNullElse returns the second if it is empty
Properties adds a lot of practical methods, mainly rewriting the related methods of hashtable.
Scanner regulars match these, findAll (Pattern/string) tokens ()
ServiceLoader added Provider findFirst () stream () load (ModuleLayer, Class). Extending spi is more practical.
List,Map,Set 's most useful static method, of (), is too convenient to create. But note that it is read-only.
Enumeration asIterator () this is also useful, returning directly to the iteration
Javax.accessibility added these visits to the AccessibilityProvider screen.
Javax.annotation.processing adds @ Generated tag to generate source code comments RoundEnvironment adds two new methods
Javax.crypto ExemptionMechanism deleted finalize
Javax.imageio deprecated part of the method added javax.imageio.plugins.tiff processing tiff format picture api
The new interface method of the main module part of the new interface of javax.lang.model
Javax.management partial method removes the addition of @ ConstructorParameters runtime judgment parameter name
Javax.naming one method to delete and deprecate
Some new properties and deprecation of javax.net.ssl
Most of the interface enhancements to javax.sql, such as DataSource,XADataSource, log creation
There are too many enhancements to javax.swing, but the interface is rarely used.
Most of the enhancements to javax.tools, such as StandardJavaFileManager, are easy to obtain according to path.
Javax.xml deleted some of the api
Other nashorn enhancements es6 (15 were killed), default toggle G1 focus doc enhancement, aot,jsheel and so on too many changes, mainly depends on the practical api.
Java10 change part
The java.io method enhances the ByteArrayOutputStream string specified encoding
PrintStream,PrintWriter print to file, practical. For example, after specifying setOut, you can write to the file according to encoding without looking at the console.
Reader added transferTo (Writer)
Java.lang.invoke
MethodType added lastParameterType () to return the last type. No, it's just void.
Several new classes added to java.lang jdk9 have been killed, and many methods enable deletion and most of the new ones are unimportant.
Java.net URLDecoder/Encoder has added the Charset of the corresponding method, which can capture exceptions by two less writes.
Java.nio Channels added a newread/write method FileStore added getBlockSize () to get the block size
Partial deprecation of java.security and its New method
Several new methods are added to java.time
Java.util.concurrent StampedLock enhances four judgment methods FutureTask rewrites tostring
It is not important to add one or two methods to individual classes in java.util.jar/spi/stream.
Some default methods have been added to java.util, and copyOf has been added to List/Map/set, which can be copied by methods.
Java.management RuntimeMXBean added pid,ThreadMXBean and two ways to get thread information. Personal expansion of this module can save a lot of jps,ps,top,jstat search.
Individual constant methods are added to most other modules
Java11 change part
Java.io reader,write,input,out these related classes and subclasses some 9 start method extension methods add fixes and so on
Java.lang.invoke added ConstantBootstraps to dynamically calculate all kinds of constants, which is practical
The clone method has been added to java.lang.ref Reference, which makes reference copying convenient.
The package java.lang is definitely important or roughly written down, partially deprecated and deleted such as Thread's stop/destroy and runtime's
Added partial encoding constant to Character inner class, and added toString method to int.
Class getNestHost nested class accesses the class array contained in getNestMembers. Is isNestmateOf a member of the class?
StringBuffer/Builder added compareTo to compare sb directly
String adds isBlank/lines/repeat/strip/stripLeading/stripTrailing utility method by looking at the name.
CharSequence added compare method comparison returned
Java.nio.fileFiles added readString and writeString Path added of. These are so practical.
Several basic types of buffer, such as ByteBuffer, have added mismatch.
Java.security most api add some methods and individual deprecation delete
Java.util.concurrent PriorityBlockingQueue extends several methods. TimeUnit adds a convert (Duration).
Java.util.function Predicate added a not.
Java.util.regex Pattern added asMatchPredicate creation predicate
Java.util.zip Deflater and Inflater have added three or four new methods for bytebuffer
ArrayList.hashcode and equals methods such as isEmpty, which are added to several java.util classes, are overridden.
Collection plus a toArray (IntFunction)
Javax.crypto.spec added ChaCha20ParameterSpec ChaCha20 algorithm javax.security.auth Policy has been deleted.
Java.corba has been deleted.
Java.desktop changes a lot of new methods, not to mention the desktop.
Change java.sql javax.transaction.xa to java.transaction.xa
Java.xml.crypto partial Enhancement
Java.xml.ws,java.xml.bind has been deleted. Download it from maven if you need it.
Add the client of http, which supports http2, so you don't need other http packages.
Java
The official version of Java12-17 17 will take 4 months to use more than 11, and few people will merge. Say, most of the finalize methods are deleted and not posted.
Java.io
@ Serial indicates that the comment field or method is part of the serialization mechanism defined by the Java object serialization specification, 14 adding
CharArrayReader add read (CharBuffer)
Console charset () gets the character set
Add read (CharBuffer) to InputStreamReader
InputStream added skipNBytes can skip byte length jdk12 addition
PrintStream added write,writeBytes (byte []) write byte array 14 add
Java.lang.annotation ElementType added RECORD_COMPONENT record class
Java.lang.constant constant package needless to say. Suitable for bytecode reading and writing API, boot, bytecode internal API and compile time or link time program analysis tools
Java.lang.invoke multiple classes and methods have to be enhanced, deprecated, etc., the main handle
RefersTo (Object) is added to java.lang.ref Reference to test whether objects are referenced, and jdk16 is added
Java.lang.reflect
New reflection component of record class added to RecordComponent
New invokeDefault static method is added to InvocationHandler. It is practical to call the proxy object directly according to the method.
Three ways to get annotations added to AnnotatedType
Java.lang.runtime this package provides low-level run-time support for the java language, and jdk14 adds
The ObjectMethods class Java compiler can use these methods to implement various method overrides under the object class, for example.
New describeConstable () instance descriptor for java.lang base type
Many character sets have been added to Character
Many abnormal getCause () such as ClassNotFoundException have been deleted. You should pay attention to it in trycatch.
NullPointerException updated getMessage () and fillInStackTrace ()
Class added hidden classes, sealed classes, record classes, inner classes, arrays, and other related methods.
Math added absExact method for int,long, absolute exact integer exceeds maximum and minimum exception, jdk15
Record this needless to say Lombok can be eliminated, note that serializable readObject and writeObject are ignored
String added formatted format characters, indent indentation, resolveConstantDesc, constant descriptor
StripIndent removes leading and trailing spaces transform allows functions to be applied to the character translateEscapes escape serialization
Thread virtual thread way to see loom project mail has been in various tests estimated to be able to catch up with 17. 5%. It's similar to go's goroutine.
Java.net
DatagramSocket added joinGroup and leaveGroup to join or leave the group, and jdk17 added
URLDecoder () has been deleted from URLDecoder.
SecureCacheResponse has added getSSLSession jdk12.
New Unix domain sockets for UnixDomainSocketAddress. The local process communicates most efficiently and only replicates data. Jdk16 is added and windows also supports it.
Java.nio.channels
New openServerSocketChannel,openSocketChannel for SelectorProvider
Add open (ProtocolFamily) to ServerSocketChannel,SocketChannel
Java.nio.file FileSystems new newFileSystem returns mismatch position according to path,Files new mismatch
Java.nio all kinds of Buffer add some cache settings, get shared compression, clear, etc.
Java.security some certificate updates, deprecate deletion methods, etc.
Java.text adds CompactNumberFormat LDML's compact digital format specification, and other ways to get it.
Simple modification of java.time Japanese fonts and other formats
Java.util.concurrent.locks LockSupport added setCurrentBlocker return object through the current thread of getBlocker
Java.util.concurrent
ThreadLocalRandom deletes nextGaussian and adds nextFloat and three makeDouble/int/longsSpliterator
Five default methods have been added to CompletionStage, and CompletableFuture also inherits automatically
Add 2 invokeAny and invokeAll to ForkJoinPool
Generic API classes and interfaces generated by java.util.random random numbers. Jdk17 new rewrite package
The multimap method has been added to the java.util.stream streaming API, which, like C++, is an associated container, and toList has also been added to Stream.
Java.util
HashSet toArray has been changed.
Tool class jdk17 for converting between HexFormat bytes, characters and hexadecimal encoded strings
Several new methods are added to Objects,Random,NoSuchElementException, and several are deleted by SplittableRandom.
Javax.crypto Cipher rewrote tostring
Javax.net.ssl HttpsURLConnection has added the getSSLSession () method, which has a
Javax.annotation.processing ProcessingEnvironment added isPreviewEnabled (), is it a preview version?
Javax.lang.model various model updates, with a lot of details that must be changed in each version, such as adding a new version of the string
Delete the ToolProvider () method of javax.tools ToolProvider
Java.util.logging LogRecord added getLongThreadID to replace getThreadID later.
Java.management.rmi deletes a lot of content.
Javax.naming.ldap.spi ldapv3 version of the expansion pack
Java.net.http HttpRequest added newBuilder (2) HttpRequest.BodyPublishers added concat
New namespace support for javax.xml DocumentBuilderFactory and SAXParserFactory
Forget about the various changes to awt,swing, eliminate a number of modules with less use, such as nashorn, and delete the enhancements under aot,jit,macos.
No conclusion, jdk16 began to enable cantilever 14, like Vector API developers need to understand HotSpot automatic vectorization support and its limitations. Panama project also has api direct access to external storage, cripple +, are you afraid of upgrading from 8.
This is the end of the content of "what are the changes from java8 to java17 api"? thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.