Java 9在9月21日正式发布,同时Oracle宣布将Java新版本的发布周期调整为每半年一次。目前,Java新版本的开发也已正式进入轨道。就已公开的消息来看,下一个版本的Java预计会在2018年3月发布,版本号将会是18.3,已经规划加入的特性包括JEP 286和296。
根据reddit站点上的讨论,首先更新的是JEP 296,Valhalla预计很快也会加入进来。OpenJDK的主页面则显示,已确定要在18.3版本实现的是JEP 286和296。
JEP 296主要是将JDK仓库群(JDK Repository Forest)合并为一个仓库,旨在降低管理大量仓库群的成本。根据InfoQ之前的报道,该仓库群的合并已经完成。这些软件仓库是在OpenJDK发展史上历次分裂生成的,在OpenJDK 9及以前的版本中将会继续存在。在这次合并操作之前,OpenJDK曾分裂为多个不同的Mercurial软件仓库群,这导致了许多问题,例如不能以原子方式对多个软件仓库应用漏洞修复(Bug Fixes)。在OpenJDK合并完成后,只会有一个软件仓库,并复制在三个开发线上。为了简化仓库的管理,JDK中还创建了用于在合并和未合并版本间移动更改的工具。
JEP 286提议在Java中引入局部变量的类型推断,该JEP在2016年提出,InfoQ曾经报道过该JEP的概况和相关的开发者调查结果。该JEP旨在减少编写Java代码相关的仪式性的内容,提升开发人员的体验,同时还要保证Java语言的静态性。它会减少开发人员在声明局部变量时,没有必要的变量类型声明。如果该JEP实现的话,在声明局部变量的时候,就可以采用类似如下的方式:
var list = new ArrayList(); // infers ArrayList var stream = list.stream(); // infers Stream
这种语句只能用于带有初始化器(initializer)的局部变量、增强的for-loop中的索引以及传统for-loop中声明的局部变量。它不能用于方法声明、构造函数声明、方法返回值、字段、catch语句以及其他类型的变量声明中。
关于局部变量的类型推断,不管是JVM体系中的语言还是其他语言都提供了一定形式的支持,比如C++(auto)、C#(var)、Scala(var/val)以及Go(通过:=进行声明)。至于该使用var作为关键字,还是使用let或类似于C/C++中的auto作为关键字,之前曾经有过一个面向开发者的调查。大约84%的回答表明定义可变内容的变量用关键字var是恰当的,只有百分之几的回答者建议使用auto更合适。根据Java语言架构师Brian Goetz介绍,该功能应该使用关键词var。
关于该特性的用法,在reddit上有一些讨论。有人表示,即便在支持“auto”语法的语言中,该特性使用的也比较少,因为有些人希望一眼就能看出变量的类型是什么。也有人认为,var有它的适用空间,在小的代码块中,直接用它实例化对象是可以的。如果是作为方法返回值的话,还是希望明确声明类型,Java的类型推断并不支持方法返回值,这一点倒不必担心。如果函数或代码块比较长的话,就不建议使用var了并要考虑适时进行代码的重写。时间和经验将会让我们更加明确应该在何时使用新功能,就像Optional刚出现时,也是耗费了一些时间才明确其推荐适用场景。
Valhalla项目中包含了一些有趣的JEP,包括值类型(Value Type)、针对原始类型实现泛型功能、增强的volatile等,外界很期待这些内容最终也能添加到新版本中。
2017慧都十四周年狂欢搞事情!砸金蛋100%抽现金红包、满额豪送iPhone X、iPhone 8、DevExpress汉化免费送、团队升级培训套包劲省10万元......更多惊喜等您来探索!

















试用、下载、了解更多产品信息请点击"咨询在线客服"
C#: MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body"); |
VB.NET: MailBee.SmtpMail.Smtp.QuickSend("from@me.com", "to@you.com", "Subject", "Message Body") |
C#: MailBee.SmtpMail.Smtp.QuickSend("From Me (Company Info)", "To you ", "Subject", "Plain text body", "HTML-formatted body", null, @"C:\My Documents\report.doc"); |
VB.NET: MailBee.SmtpMail.Smtp.QuickSend("From Me (Company Info)", _ "To you ", _ "Subject", "Plain text body", _ "«html»HTML-formatted body«/html»", _ Nothing, "C:\My Documents\report.doc") |
C#: Smtp oMailer = new Smtp(); |
VB.NET: Dim oMailer As New Smtp() |
C#: oMailer.SmtpServers.Add("smtp.domain.com"); |
VB.NET: oMailer.SmtpServers.Add("smtp.domain.com") |
C#: oMailer.SmtpServers.Add("127.0.0.1"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1") |
C#: oMailer.SmtpServers.Add("smtp.domain.com","login","password"); |
VB.NET: oMailer.SmtpServers.Add("smtp.domain.com","login","password") |
C#: oMailer.SmtpServers.Add("127.0.0.1","login","password"); |
VB.NET: oMailer.SmtpServers.Add("127.0.0.1","login","password") |
C#: oMailer.From.AsString = "Dan Brown (Company Info)"; |
VB.NET: oMailer.From.AsString = "Dan Brown (Company Info)" |
C#: oMailer.From.AsString = "Dan Brown "; |
VB.NET: oMailer.From.AsString = "Dan Brown " |
C#: oMailer.From.AsString = "dan@domain.com"; |
VB.NET: oMailer.From.AsString = "dan@domain.com" |
C#: oMailer.To.AsString = "Bill Smith (Remarks), Kathy@mail.com "; oMailer.Cc.AsString = "Joe Black , Joseph "; oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com"; oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones "; |
VB.NET: oMailer.To.AsString = "Bill Smith (Remarks), Kathy@mail.com " oMailer.Cc.AsString = "Joe Black , Joseph " oMailer.Bcc.AsString = "t.jay@domain.com, s.connor@domain.com" oMailer.ReplyTo.AsString = "john@domain.com, Barbara Jones " |
C#: oMailer.Subject = "Test message"; |
VB.NET: oMailer.Subject = "Test message" |
C#: oMailer.BodyPlainText = "This is a test e-mail message."; |
VB.NET: oMailer.BodyPlainText = "This is a test e-mail message." |
C#: oMailer.BodyHtmlText = @" Test HTML message.
www.afterlogic.com"; |
VB.NET: oMailer.BodyHtmlText = " Test HTML message. " & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "www.afterlogic.com" |
C#: oMailer.AddAttachment(@"C:\annual_reoprt.xls"); oMailer.AddAttachment(@"C:\deposits.doc"); |
VB.NET: oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.AddAttachment("C:\deposits.doc") |
C#: try { oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail); } |
VB.NET: Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: " + e.RefusedRecipientEmail) End Try |
C#: using System; using MailBee; using MailBee.SmtpMail; namespace EmailApp { class Class1 { [STAThread] static void Main(string[] args) { Smtp oMailer = new Smtp(); oMailer.From.AsString = "John Doe (Company Info)"; oMailer.To.AsString = "Bill Smith , Kathy Ritchie (Company Info)"; oMailer.Subject = "Test e-mail"; oMailer.BodyPlainText = "This is a test e-mail message."; oMailer.BodyHtmlText = @" Test HTML message.
www.afterlogic.com"; oMailer.AddAttachment(@"C:\annual_reoprt.xls"); oMailer.SmtpServers.Add("127.0.0.1", "login", "password"); oMailer.SmtpServers[0].AllowRefusedRecipients = false; try { oMailer.Send(); Console.WriteLine("The message has been successfully sent."); } catch (MailBeeSmtpRefusedRecipientException e) { Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail); } } } } |
VB.NET: Imports System Imports MailBee Imports MailBee.SmtpMail Namespace EmailApp Class Class1 _ Shared Sub Main(ByVal args() As String) Dim oMailer As New Smtp() oMailer.From.AsString = "John Doe (Company Info)" oMailer.To.AsString = "Bill Smith , Kathy Ritchie (Company Info)" oMailer.Subject = "Test e-mail" oMailer.BodyPlainText = "This is a test e-mail message." oMailer.BodyHtmlText = " Test HTML message. " & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "www.afterlogic.com" oMailer.AddAttachment("C:\annual_reoprt.xls") oMailer.SmtpServers.Add("127.0.0.1", "login", "password") oMailer.SmtpServers(0).AllowRefusedRecipients = False Try oMailer.Send() Console.WriteLine("The message has been successfully sent.") Catch e As MailBeeSmtpRefusedRecipientException Console.WriteLine("The following recipient was refused by SMTP server: "+ e.RefusedRecipientEmail) End Try End Sub End Class End Namespace |
C#
Console.WriteLine("Attachment name is " + msg.Attachments[0].Name);
VB.NET
Console.WriteLine("Attachment name is " + msg.Attachments(0).Name)C#
Pop3 pop = new Pop3();
// Download entire message
MailMessage msg = pop.DownloadEntireMessage(1);
if (msg.HasAttachments)
{
// The message has at least one attachment
}
VB.NET
Dim pop As New Pop3()
' Download entire message
Dim msg As MailMessage = pop.DownloadEntireMessage(1)
if (msg.HasAttachments) Then
' The message has at least one attachment
End IfMicrosoft发布了安全公告MS 17-005,它为各种版本的Windows提供了一些补丁。这些补丁(全部称为KB 4010250)启动Adobe APSB17-04中的Flash Player修复程序,修复了13个关键漏洞。微软用了一个星期的时间来修复漏洞。
这些补丁现在可以通过Windows Update在设备上运行:
Windows 8.1,RT 8.1和运行Internet Explorer 11的Server 2012 R2
Internet Explorer 10的Server 2012
所有版本的Windows 10 - RTM(1507),1511,1607和Server 2016
