我正在更改我们的Java类,我注意到以下代码行:
OurClass<OurInterface1> ourClass = new OurClass<OurInterface1>() {};
Run Code Online (Sandbox Code Playgroud)
我对这一行感到奇怪的是,这OurClass是一个抽象类 - 这里的定义是OurClass:
public abstract class OurClass<T extends OurInterface1> implements OurInterface2<T>
Run Code Online (Sandbox Code Playgroud)
当我删除{}行尾时,Eclipse告诉我Cannot instantiate the type OurClass<OurInterface1>,但是当我放{}回去时,一切都很好.
如何{}允许您实例化一个抽象类?
根据HP Fortify文档,静态代码分析器首先将源代码转换为中间格式,然后扫描已翻译的代码并生成漏洞报告.
它说翻译可以使用以下Ant代码完成:
<antcall target="compile">
<param name="build.compiler" value="com.fortify.dev.ant.SCACompiler"/>
</antcall>
Run Code Online (Sandbox Code Playgroud)
这将调用您的"编译"目标,但强制它使用SCAC编译器而不是常规的javac编译器.
我已经在我们的Java代码上运行Fortify,它会生成漏洞报告.但是我没有在任何地方看到中间文件.我在常规javac编译器生成的Java类文件和SCACompiler生成的Java类文件之间运行了差异,它们完全相同.中间文件是否存储在其他地方,或Fortify在执行扫描后是否会自动删除它们?
我在Perl脚本中尝试了以下内容:
$b = 19999999999999999 % 10000000000000000;
print "$b\n";
Run Code Online (Sandbox Code Playgroud)
它输出错误0.
然后我找到一个答案说使用bignum:
use bignum;
$b = 19999999999999999 % 10000000000000000;
print "$b\n";
Run Code Online (Sandbox Code Playgroud)
它输出正确9999999999999999.
但bignum只需将所有整数常量转换为Math :: BigInt.所以我尝试了以下哪些应该与使用相同bignum:
use Math::BigInt;
$b = Math::BigInt->new(19999999999999999) % Math::BigInt->new(10000000000000000);
print "$b\n";
Run Code Online (Sandbox Code Playgroud)
但那输错了0.我在使用Math :: BigInt做错了吗?
我有以下 Perl 代码:
my $athCombined = "$athSymbol $athExpiration $athStrike $athType";
if (($instrumentType eq "STOCK" && $cbSymbol ne $athSymbol) ||
($instrumentType eq "OPTION" && $cbSymbol !~ /^$athSymbol.*$athExpiration $athStrike $athType$/) ||
($instrumentType eq "FUTURESOPTION" && $cbSymbol !~ /^$athCombined$/)) {
print "ERROR: Symbols on lines $cbLineNum and $athLineNum don't match. ABORTING.\n";
print "instrumentType =$instrumentType\n";
print "cbSymbol =$cbSymbol\n";
print "athCombined =$athCombined\n";
print "length cbSymbol =" . length($cbSymbol) . "\n";
print "length athCombined=" . length($athCombined) . "\n";
if ($instrumentType eq "FUTURESOPTION") {
print "YES1\n";
} …Run Code Online (Sandbox Code Playgroud)