我有一个关于java中的默认构造函数的问题.
尽管我已经阅读了java中的构造函数,但默认构造函数会将所有实例变量初始化为其默认值.但是如果我们为一个类定义一个构造函数,那么如果我们想要它们,变量如何初始化为默认值呢?
假设我有2个文件a.java
public class a
{
int x;
public a(int z)
{
if(z > 0)
{
x = z;
}
}
public void get()
{
System.out.println(x);
}
}
Run Code Online (Sandbox Code Playgroud)
和b.java
public class b
{
public static void main(String[] args)
{
a obj = new a(-4);
obj.get();
}
}
Run Code Online (Sandbox Code Playgroud)
现在这里条件(z> 0)失败,所以x被初始化为零.但这究竟是什么,因为它们在类a中没有默认构造函数.
在CQ中,如果我请求诸如的资源localhost:4502/content/geometrixx/en.json
,我将获得JSON格式的节点信息.这同样适用于XML扩展.
我的问题是,如果URL扩展名为json
?,它实现了哪些节点信息以JSON格式呈现?基本上,扩展只是文本和URL结构的另一部分.简单地追加json
不会神奇地获取JSON格式的信息.
显然,必须使用此信息来编写用于以JSON格式返回节点信息的逻辑.
我正在努力了解CQ的内部工作原理.也许在Apache Sling中获取JSON的概念也是一样的?我不知道它是否具体是CQ,但重点是相同的.我也试过/system/console/jcrresolver
了,但没有用.
当在QualityProfile中使用FxCop规则时,MSBuild SonarQube提出了“必须设置sonar.cs.fxcop.assembly”的问题。请参阅下面的异常。
它可以与其他StyleCop和C#规则配合使用。我看过类似的帖子,但找不到解决方案。
我在用 :
C:\Sonar\sonarqube-5.2
C:\Sonar\MSBuild.SonarQube.Runner-1.0.2
Run Code Online (Sandbox Code Playgroud)
已安装以下插件:插件C#4.3插件StyleCop 1.1
针对以下示例项目:
C:\Sonar\sonar-examples-master\projects\languages\csharp\ConsoleApplication1
Run Code Online (Sandbox Code Playgroud)
我正在执行以下命令:
cd Sonar\MSBuild.SonarQube.Runner-1.0.2\
MSBuild.SonarQube.Runner.exe begin /k:"MyProjectKey" /n:"MyProjectName" /v:"MyProjectVersion"
"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "C:\Sonar\sonar-examples-master\projects\languages\csharp\ConsoleApplication1\ConsoleApplication1.csproj" /t:Rebuild
MSBuild.SonarQube.Runner.exe end
Run Code Online (Sandbox Code Playgroud)
我试图在.csproj文件中声明程序集的位置,但是没有成功。预期路径是什么样的?
<ItemGroup>
<SonarQubeSetting Include="sonar.cs.fxcop.assembly">
<Value>path to dll</Value>
</SonarQubeSetting>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助 !
例外情况:
10:33:14.564 INFO - Sensor org.sonar.plugins.csharp.CSharpFxCopProvider$CSharpF
xCopSensor@1eeeda8
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 12.017s
Final Memory: 14M/113M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher
.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) …
Run Code Online (Sandbox Code Playgroud) 我想问一下javap除了传递给它的类的公共字段和方法之外还显示什么。
我正在查看一个只有一个静态变量的类文件。正如预期的那样,javap 将静态变量和类构造函数显示为输出,但它也显示如下内容:
static {};
Run Code Online (Sandbox Code Playgroud)
这条线是什么意思?