在我更新Android Studio和SDK后,我确实收到了这些错误:
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.apache.log4j.chainsaw.ControlPanel$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner …Run Code Online (Sandbox Code Playgroud) 我尝试在 tsql 中保留换行符。所以我想删除字段中数据的前导 CHAR(13) + CHAR(10)。并确保其他换行符不会被删除。
我的意思是:
'
Kanne Oliver
Rosa-Luxemburg-Str. 3
07817 Alton ( Elster)'
Run Code Online (Sandbox Code Playgroud)
应该是这样的:
'Kanne Oliver
Rosa-Luxemburg-Str. 3
07817 Alton ( Elster)'
Run Code Online (Sandbox Code Playgroud)
先谢谢了
目前,我正在尝试获取静态上下文中从 BaseTest 继承的任何底层类的类名。@BeforeClass因此,为了进行解释,我正在编写一个使用junit 的基类。这里的问题是我在类的所有测试之前启动一个假应用程序,它有自己的内存 h2 数据库。我想将数据库命名为测试类,这样我以后就可以看到每次测试写入数据库的内容。
基础测试:
public abstract class BaseTest {
private static final Map<String, String> testConfig = getTestConfig();
private static FakeApplication fakeApplication;
@BeforeClass
public static void onlyOnce(){
fakeApplication = Helpers.fakeApplication(testConfig);
Helpers.start(fakeApplication);
}
@AfterClass
public static void afterClass(){
Helpers.stop(fakeApplication);
fakeApplication = null;
}
private static Map<String, String> getTestConfig() {
//Here should bee FooTest in this case! But actually it's BaseTest
String className = MethodHandles.lookup().lookupClass().getSimpleName();
...
configs.put("db.default.url", "jdbc:h2:file:./data/tests/" + className + ";AUTO_SERVER=TRUE;MODE=Oracle;DB_CLOSE_ON_EXIT=FALSE");
}
Run Code Online (Sandbox Code Playgroud)
例如一些儿童测试:
public class FooTest extends …Run Code Online (Sandbox Code Playgroud) 想象一下接下来的课程
@Embeddable
class A {
@ManyToOne
public B classB;
...
public State someEnum;
}
@Entity
@Table(name = "TEST")
class B {
public long id;
//... some data
@Embedded
@AttributeOverrides({
@AttributeOverride(
name = "classB.id",
column = @Column(name = "EMBEDDED1_ID")
),
@AttributeOverride(
name = "someEnum",
column = @Column(name = "EMBEDDED1_SOMEENUM")
)
})
public A embedded1;
@Embedded
@AttributeOverrides({
@AttributeOverride(
name = "classB.id",
column = @Column(name = "EMBEDDED2_ID")
),
@AttributeOverride(
name = "someEnum",
column = @Column(name = "EMBEDDED2_SOMEENUM")
)
})
public A embedded2;
} …Run Code Online (Sandbox Code Playgroud) 我正在使用命令“jmap -histo pid”,想知道它到底告诉我什么。
输出类似于:
num #instances #bytes class name
----------------------------------------------
1: 2284437 262114728 [C
2: 686409 124390432 [B
3: 363878 46799288 <constMethodKlass>
4: 363878 46590464 <methodKlass>
5: 1817209 43613016 java.lang.String
6: 34590 37296528 <constantPoolKlass>
7: 296302 36673344 [I
8: 34585 33237656 <instanceKlassKlass>
9: 248731 21559504 [Ljava.lang.Object;
10: 28200 19991872 <constantPoolCacheKlass>
11: 563323 13519752 scala.collection.immutable.$colon$colon
12: 26813 13103488 <methodDataKlass>
13: 506968 12167232 scala.collection.immutable.HashSet$HashSet1
14: 200750 10371320 [Lscala.collection.immutable.HashSet;
15: 114268 9477096 [Lscala.collection.immutable.HashMap;
16: 92405 7392400 java.lang.reflect.Method
17: 200953 6430496 scala.collection.immutable.HashMap$HashMap1
Run Code Online (Sandbox Code Playgroud)
举例来说:“字节”到底显示什么?
我想创建一个通用方法来组合集合.
public class CollectionsHelper {
public static Set<?> combineSets(Set<?> set1, Set<?> set2){
return Collections.unmodifiableSet(new HashSet<?>() {{
addAll(set1);
addAll(set2);
}});
}
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了编译错误:
通配符类型'?' 无法直接实例化
我想通过定义泛型类的类型来创建一个实例
public abstract class Base<T> {
private final T genericTypeObject;
protected Base(){
//Create instance of T here without any argument
}
}
Run Code Online (Sandbox Code Playgroud)
这样我就可以调用默认构造函数:
public class Child extends Base<SomeClass>{
public Child () {
super();
}
}
Run Code Online (Sandbox Code Playgroud)
基类实现将为我创建一个 GenericType 的实例。
我想转换以下字符串:
private String cw = "35/19"
Run Code Online (Sandbox Code Playgroud)
分成 2 个日期。
开始日期可以格式化为:
private final DateTimeFormatter startOfWeekFormat = new DateTimeFormatterBuilder()
.appendPattern("ww/YY")
.parseDefaulting(WeekFields.ISO.dayOfWeek(), 1)
.toFormatter();
Run Code Online (Sandbox Code Playgroud)
调用时返回:26.08.2019
LocalDate.parse(cw, startOfWeekFormat).atStartOfDay();
Run Code Online (Sandbox Code Playgroud)
但我在本周结束时挣扎,这基本上是下周“36/19”的开始。
我尝试添加 plus 8 天,但这会引发异常:
private final DateTimeFormatter endOfWeekFormat = new DateTimeFormatterBuilder()
.appendPattern("ww/YY")
.parseDefaulting(WeekFields.ISO.dayOfWeek(), 8)
.toFormatter();
Run Code Online (Sandbox Code Playgroud) 我正在尝试做一个简单的if语句使用?图案.导致"不是声明" - 错误.有人可以向我解释为什么使用正常的if语句不会发生这种情况?
错误:
cursor.isNull(0) ? insert_SQL_RSServer.bindNull(0) : insert_SQL_RSServer.bindLong(0, cursor.getLong(0)); // id
Run Code Online (Sandbox Code Playgroud)
没错误:
if(cursor.isNull(0))
insert_SQL_RSServer.bindNull(0);
else
insert_SQL_RSServer.bindLong(0, cursor.getLong(0));
Run Code Online (Sandbox Code Playgroud)
这是完全相同的行为....
java ×6
android ×2
generics ×2
build ×1
build.gradle ×1
date ×1
dependencies ×1
embeddable ×1
formatting ×1
hibernate ×1
jmap ×1
jpa ×1
junit ×1
jvm ×1
memory ×1
newline ×1
static ×1
t-sql ×1
trim ×1