Clojure에서 클래스를 연장하는 문제 : Classformaterror : 중복 필드 이름 및 서명
문제
나는 Clojure로 jbutton을 확장하려고 노력하고 있지만 내 자신의 생성자를 만들려고 할 때 문제가 발생했습니다. 내가 사용할 때마다 :constructors
~와 함께 :gen-class
수업을 인스턴스화하려고 할 때 "Classformaterror : Duplication Field Name & Signature"메시지를 계속받습니다.
나 생각한다 나는 따라야한다 Clojure Docs 제대로. 내가 뭔가 잘못하고 있습니까?
예시:
(ns test.gui.button
(:gen-class
:extends javax.swing.JButton
:constructors {[] [String]}
:init init))
(defn -init []
[["Click Me"] nil])
해결책
JButton
확장 javax.swing.AbstractButton
이미 보호 된 것입니다 init
방법. clojure-init 함수의 이름을 예를 들어, my-init
문제는 사라졌습니다.
(ns test.gui.button
(:gen-class
:extends javax.swing.JButton
:constructors {[] [String]}
:init my-init))
(defn -my-init []
[["Click Me"] nil])
제휴하지 않습니다 StackOverflow