스크립트 안에서 맵을 얕게 복사해 두고 키 하나의 값을 나중에 바꾸고 싶어요. 스프레드 연산자를 쓰면 되긴 하죠. 그런데 Jenkins 파이프라인에서 실행하고, 조직 정책상 그 연산자를 쓸 수 없어요.
clone() 메서드 호출은 성공하지만 Intellij가 "Access to 'clone' exceeds its access rights"라고 알려 줘요. Jenkins readJSON으로 맵을 만들기 때문에 clone() 메서드 자체를 구현하지 않은 맵 비슷한 객체가 나올 수도 있다는 게 이유의 일부예요.
스프레드 연산자를 제외하면 맵을 얕게 복사하는 가장 관용적인 방법은 뭔가요?
영어에서 번역·원문 보기I need to create a shallow duplicate of a map inside my script, allowing me to change one of its keys afterwards. The spread operator provides one approach. But this runs inside a Jenkins pipeline, and our organization's policy disallows that operator.
Calling the clone() method succeeds, though Intellij reports "Access to 'clone' exceeds its access rights". This is partly due to the map having been created through Jenkins readJSON, which might supply a map-like object that doesn't implement the clone() method itself.
Which approach, excluding the spread operator, is most idiomatic for shallow map copying?