好吧,这个问题可能不多说,但是这里是交易:我正在学习scala并决定使用一个方法来创建一个实用程序类"FuncThread",该方法接收一个名称参数函数(我想它之所以称之为因为它是一个函数但是没有参数列表)然后启动一个带有runable的线程,然后执行传递的函数,我写了这样一个类,如下所示:
class FuncThread
{
def runInThread( func: => Unit)
{
val thread = new Thread(new Runnable()
{
def run()
{
func
}
}
thread.start()
}
}
Run Code Online (Sandbox Code Playgroud)
然后我写了一个junit测试如下:
@Test
def weirdBehaivorTest()
{
var executed = false
val util = new FuncThread()
util.runInThread
{
executed = true
}
//the next line makes the test pass....
//val nonSense : () => Unit = () => { Console println "???" }
assertTrue(executed)
}
Run Code Online (Sandbox Code Playgroud)
如果我取消注释第二个注释行,则测试通过,但如果它仍然被注释,则测试失败,这是正确的行为吗?by-name参数函数如何以及何时执行?
我知道Scala有actor库但我想尝试这个,因为我一直想用Java做这个
在学校,我们被分配设计一种语言,然后实施它,(我实现它很有趣=)).我的老师告诉我们使用yacc/lex,但我决定使用java + regex API,这就是我设计的语言的样子:
Program "my program"
var yourName = read()
if { equals("guy1" to yourName) }
print("hello my friend")
else
print("hello extranger")
end
Program End
Run Code Online (Sandbox Code Playgroud)
好吧,正如你所看到的,它是一种非常基本的语言=).
我以为我可以以一种非常OOP的方式实现它,比如创建一个抽象类Sentence然后有子类等VariableAssignment,IfSentence并且有一个Program只有一堆句子的类吧?然后eval在所有Sentences 上调用一个抽象方法,所以我最初编译语言的方法只包括两个阶段:
当然,如果在任何阶段出现问题,Ii都可能引发错误.
我的问题是,我做错了吗?我应该像理论一样(词汇,句法,语义)来讨论所有阶段吗?我应该继续使用我天真的两阶段编译器吗?
我正在开发一个Web应用程序,它的servlet基本上充当Web服务的前端,我使用CXF作为Web服务客户端,应用程序在WebLogic 9.10服务器上运行,每个东西都工作正常,直到项目所有者决定添加ssl supprt,没什么大问题,因为我使用cxf whitout spring,我设法在服务客户端的http管道中配置TLS参数,还配置了一个密钥库,用于服务器密钥,ca根证书和客户端证书,在开发tomcat实例下测试并且工作正常.
当应用程序再次将应用程序重新部署到weblogic服务器并开始出现奇怪的错误时,问题就出现了,首先是:
java.lang.ClassCastException: com.sun.xml.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy
at org.apache.cxf.frontend.ClientProxy.getClient
Run Code Online (Sandbox Code Playgroud)
然后我意识到weblogic正在加载它自己的JAX-WS实现,没有问题,只是添加了weblogic.xml whit"prefer-web-inf-classes"设置为true,重新部署,现在我得到了这个例外:
java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.ws.Service.<init>(Ljava/net/URL;Ljavax/xml/namespace/QName;)V" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, com/adinfi/imgsvc/cm/service/CMBGenericWebServiceService, and the class loader (instance of <bootloader>) for resolved class, javax/xml/ws/Service, have different Class objects for the type javax/xml/namespace/QName used in the signature
Run Code Online (Sandbox Code Playgroud)
那个人得到了我,我认为类路径有问题,所以我开始从应用程序中删除jar并仍然有更多的链接错误,最后一个我得到的是:
java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/w3c/dom/UserDataHandler"
Run Code Online (Sandbox Code Playgroud)
这就是我的应用程序的"Web-Inf/lib /"目录现在的样子: …