我在 Vue 组件中使用以下路由器链接:
<router-link :to="{ name: 'home'}"></router-link>
Run Code Online (Sandbox Code Playgroud)
我的应用程序的其余部分如下:
路由器.js
new VueRouter({
mode: "history",
routes: [
{
name: 'home',
path: '/home',
component: home,
}
]})
Run Code Online (Sandbox Code Playgroud)
主程序
new Vue({
render: (h) => h(App),
router,
}).$mount("#app");
Run Code Online (Sandbox Code Playgroud)
使用路由器链接时出现以下错误,但 router.push() 与路由一起工作正常。
TypeError: Cannot read property '_normalized' of undefined (vue.min.js:6)
Run Code Online (Sandbox Code Playgroud) 分析这个简单类的字节码,我得出的结论是编译器不保留有关局部变量的任何信息final.这看起来很奇怪,因为我相信HotSpot编译器实际上可以使用这些信息来进行优化.
代码:
public static void main(String[] args)
{
final int i = 10;
System.out.println(i);
}
Run Code Online (Sandbox Code Playgroud)
字节码:
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=1
0: bipush 10
2: istore_1
3: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;
6: bipush 10
8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V
11: return
LineNumberTable:
line 7: 0
line 8: 3
line 9: 11
LocalVariableTable:
Start Length Slot Name Signature
0 12 0 args [Ljava/lang/String;
3 9 1 i …Run Code Online (Sandbox Code Playgroud) 请考虑以下提交历史记录:
1---R---3---5---P-> # patch-v1.1
\ \
2---4---+---8---+---10---R-> # release-v2.0
\ /
6---7---9 # feature-foo
--> time
# 1 - 10 are commits
# P is a patch release commit
# R are major release commits
# + marks a merge commit
Run Code Online (Sandbox Code Playgroud)
我想生成更改日志release-v2.0,但由于P (patch-v1.1)已经发布,它的更改不应该是v2.0更改日志的一部分.我可以将git log命令配置为仅列出提交2, 4, 6 .. 11(即,来自release-v2.0和的提交feature-foo)吗?
以下签名在Scala中有效且常用:
trait Collection[A] {
def reduceLeft [B >: A] (f: (B, A) => B): B
}
Run Code Online (Sandbox Code Playgroud)
但是,由于Java中>:的Scala是等效的super,我转换此签名的第一个想法(用函数类型替换BiFunction并使用Use-Site variance annotations aka Bounded Wildcards)将是
interface Collection<A> {
<B super A> B reduceLeft(BiFunction<? super B, ? super A, ? extends B> mapper)
}
Run Code Online (Sandbox Code Playgroud)
但是哦,不!编译器抱怨super令牌,<B super A>因为你不能有低边界的类型变量!现在,如何在Java代码中编写此方法而不必回顾Java世界中不存在泛型的时间?
是的,我知道你认为我可以使用B extends A,但这不是一回事,正如我的实现所示:
public <R extends E> R reduceLeft(BiFunction<? super R, ? super E, ? extends R> mapper)
{
if (this.isEmpty())
{
return …Run Code Online (Sandbox Code Playgroud) 我正在从Java C的面向对象编程的介绍中进行练习.Thomas Wu.
第73页提供了请求全名的代码,使用分隔符对其进行标记并将其打印回来.
import java.util.*;
class Scanner1
{
public static void main(String[] args)
{
String name;
Scanner scanner = new Scanner(System.in);
scanner.useDelimiter(System.getProperty("line.separator"));
System.out.print("Enter full name (first, middle, last)");
name = scanner.next( );
System.out.println("you entered " + name + ".");
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,我似乎不想打印回来,它冻结了程序,迫使使用任务管理器关闭它.
它编译并且没有错误.我已经多次检查拼写错误等.
如果我删除分隔符部分(最后一张图片),它会将第一个令牌放到第一个空格.所以错误位于分隔符代码周围.
有关上下文,请首先阅读有关三元运算符的问题。
我正在构建自己的编程语言,允许您定义自定义运算符。因为我希望它具有尽可能少的编译器内置函数,所以它应该允许定义自定义三元运算符,最好采用以下形式
infix operator ? : { precedence 120 }
Run Code Online (Sandbox Code Playgroud)
我的(手写的)表达式解析器会将嵌套的三元运算符转换为由运算符分隔的操作数列表。
a ? b ? c : d : e
(a) ? (b) ? (c) : (d) : (d)
OperatorChain(operators: [?, ?, :, :], operands: [a, b, c, d, e])
Run Code Online (Sandbox Code Playgroud)
该类OperatorChain现在从范围内的运算符定义中查找运算符,并使用调车场算法的修改版本将列表转换为二进制 AST 节点,如下所示:
// Note: OperatorElement is a class that merely stores an Identifier, an associated source code position and the resolved operator.
// IValue is the base interface for all Expression AST nodes
final Stack<OperatorElement> …Run Code Online (Sandbox Code Playgroud) 作为我正在编写的编程语言的编译器的一部分,我在字节码中遇到了通用签名,我试图解析并转换为AST.解析算法大多数都有效,但似乎有一种特殊情况,这些签名的格式有点奇怪.以下是一些这样的情况:
java.util.Arrays#parallelSort: <T::Ljava/lang/Comparable<-TT;>;>([TT;)V
java.util.Arrays#parallelSort: <T::Ljava/lang/Comparable<-TT;>;>([TT;II)V
java.lang.Class#getAnnotation: <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)TA;
java.lang.Class#getAnnotationsByType: <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)[TA;
java.lang.Class#getDeclaredAnnotation: <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)TA;
java.lang.Class#getDeclaredAnnotationsByType: <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)[TA;
java.util.Arrays#parallelSort: <T::Ljava/lang/Comparable<-TT;>;>([TT;)V
java.util.Arrays#parallelSort: <T::Ljava/lang/Comparable<-TT;>;>([TT;II)V
java.util.Collections#sort: <T::Ljava/lang/Comparable<-TT;>;>(Ljava/util/List<TT;>;)V
Run Code Online (Sandbox Code Playgroud)
在这些类中的所有方法中,这些是唯一具有::签名的方法.我的问题是这个令牌的作用以及它存在的原因.
编辑
我知道Java语言中的::运算符,但这是字节码级别的内容.
考虑以下 Swift 表达式
println(Generic<Foo, Bar>(1))
Run Code Online (Sandbox Code Playgroud)
Normally, one would read this as a generic call to the constructor Generic<Foo, Bar> with the arguments (1).
println( Generic<Foo,Bar>(1) )
Run Code Online (Sandbox Code Playgroud)
However, when re-arranging the tokens a bit, it could also represent two separate comparisons, for example if Generic and Foo were some poorly named numeric variables:
println(Generic < Foo, Bar > (1))
// or, with proper parenthesis
println((Generic < Foo), (Bar > 1))
Run Code Online (Sandbox Code Playgroud)
What we can observe here is that an expression with …
要告诉 JVM 在 Jar 文件的主类之前调用 Java Instrumentation 代理,通常必须使用命令选项调用它:
java -javaagent:agent.jar program.jar
Run Code Online (Sandbox Code Playgroud)
每次都必须输入这个非常不方便,那么有没有办法在program.jar清单中指定代理?
# program.jar/META-INF/MANIFEST.MF
...
Java-Agent: agent.jar
Run Code Online (Sandbox Code Playgroud) 我使用 Apache POI 创建了一个 Excel 文件。现在我想使用 Apache POI 本身或 PDFBox 将其转换为 PDF。
根据要求,我不能使用 itext 将 excel 转换为 PDF 或除 Apache POI 或 PDFBox 以外的任何其他 API。
java ×7
generics ×2
jvm ×2
jvm-bytecode ×2
algorithm ×1
ambiguity ×1
apache-poi ×1
delimiter ×1
final ×1
git ×1
git-branch ×1
git-log ×1
jar ×1
javaagents ×1
manifest ×1
parsing ×1
pdfbox ×1
scala ×1
swift ×1
vue.js ×1