假设我有一个包含多个构造函数的类,其中一个是复制构造函数(复制对象):
public class Rectangle {
int width, height;
public Rectangle(int width, int height) {
this.width = width;
this.height = height;
}
public Rectangle(Rectangle source) {
this(source.width, source.height);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有什么办法可以让检查,如果source是null在拷贝构造函数和抛出IllegalArgumentException,如果它是什么?因为其他构造函数调用必须是我的构造函数中的第一个语句.
作为C++的新手,我一直在玩指针.我编写了以下代码来将短数组解释为整数:
#include <iostream>
int main(){
short array[2] = {10, 9};
short* pointer = array;
std::cout << pointer << ": " << *pointer << std::endl;
// 0xffffcbdc: 10
pointer++;
std::cout << pointer << ": " << *pointer << std::endl;
// 0xffffcbde: 9
int* pointer2 = (int*) array;
std::cout << pointer2 << ": " << *pointer2 << std::endl;
// 0xffffcbdc: 589834
}
Run Code Online (Sandbox Code Playgroud)
为什么整数589'834(0009 000A)而不是655'369(000A 0009)的值?
从打印的指针地址看起来,数组在内存中是有序的,为什么转换为整数更改呢?
我在依赖 JAAS 登录的应用程序之一中使用 Vaadin Push。似乎存在两种框架发生冲突的情况。
我已经配置了这样的安全约束:
<!-- This is the exclusion I talk about below -->
<security-constraint>
<web-resource-collection>
<web-resource-name>ecomsupportform</web-resource-name>
<url-pattern>/app/PUSH</url-pattern>
</web-resource-collection>
</security-constraint>
<!-- This is the exclusion I talk about below -->
<security-constraint>
<web-resource-collection>
<web-resource-name>ecomsupportform</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>any</description>
<role-name>*</role-name>
</security-role>
Run Code Online (Sandbox Code Playgroud)
当我在会话超时后刷新页面时,会显示登录页面。但随后 Vaadin 似乎想通过 Atmosphere 向服务器发送关闭请求来关闭 Push-Session,JBoss 注意到并阻止了这一请求,因为我尚未登录。虽然我不知道 Push-Session 发生了什么,但当我知道登录时,JBoss 会将我重定向到.../PUSHVaadin 之前发送的 -URL。出现空白屏幕。
我尝试PUSH通过将 -Request 排除在身份验证之外来阻止 JBoss 捕获该请求。现在,当 Vaadin 发送关闭请求时,浏览器会在网络选项卡中显示 500(而不是 401 HTTP 响应代码),当我登录时,也会发生同样的情况。
我还尝试将“推送”设置为“手动”模式,或使用许多不同的传输机制。
PS:如果有帮助的话。当我登陆登录页面并在登录之前重新加载时,一切正常。
有什么办法可以防止JBoss登录后像这样重定向吗?或者我可以用其他方式解决这个问题吗?
java ×2
arrays ×1
atmosphere ×1
c++ ×1
constructor ×1
jaas ×1
jboss6.x ×1
pointers ×1
vaadin7 ×1